Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set an API key when using Google's script loader?

I registered my project and generated a browser key at https://code.google.com/apis/console/.

Now how do I use that key when using the Google Script Loader?

I've been doing this, which works (with or without the key parameter), but even after several weeks the API console shows no requests:

<script src=//www.google.com/jsapi?key=my_key"></script>
<script>
    google.load('maps', '3.10', { other_params : 'libraries=places&sensor=false', callback : ... })
</script>
like image 436
ejain Avatar asked Jan 19 '13 01:01

ejain


People also ask

How do I authorize API key?

API key. With API key auth, you send a key-value pair to the API either in the request headers or query parameters. In the request Authorization tab, select API Key from the Type list.


1 Answers

The key is useless for the jsapi, you must append it to other_params:

<script>
    google.load('maps', '3', {
        other_params: 'key=my_key',
        callback: function(){}
    });
</script>
like image 112
Dr.Molle Avatar answered Sep 29 '22 20:09

Dr.Molle