Invalid Google Maps V3 API Key - But My Private Key Key Works

Recently I was engaged in development, updating our maps to version v3, and during development I used my private key. Everything is working fine. When it came time to go to production, someone generated a key for me through the google account of the company, and now it does not work. I sat next to them, making sure they generated the browser key, and I’m sure that the domains are correct in the Referrer section corresponding to both: .mydomain.com / mydomain.com/*

I checked that we use Key for browser applications.

I have confirmed that the Google Maps API v3 is enabled through the services panel. Everything is identical to how I did this with my key. I think the only difference is that they activated Billing on the company account, where, like my key, no. We would like this to change my key, as it received more than 25 thousand views / daily limit on my account.

When using the company’s API key, the map loads, and then very quickly I get a warning window saying: “Google has disabled the use of the Maps API for this application. The provided key is not a valid Google API key, or it is not allowed for the Javascript Google Maps v3 API on this site. If you are the owner of this application, you can find out about obtaining a valid key here: https://developers.google.com/maps/documentation/javascript/tutorial#api_key "

If I replaced the key with my key, with the same referrers settings, it works.

Any help would be greatly appreciated.

+10
javascript google-maps-api-3
source share
11 answers

I managed to solve this problem by simply creating a new browser key. I generated, threw it into the browser, the map loaded. Then I went in and copied my referrers from the previous key. Saved. Refreshed. And he still worked. I honestly think that this was a mistake at the end of Google, and that day when we generated the original keys, it issued invalid keys.

+9
source share

You miss v=3 before key={yourkey}

Like this:

 maps.googleapis.com/maps/api/js?v=3&key={your key}&sensor=false 
+21
source share

In fact, you want to include the Google Maps JavaScript API instead of the Google Maps API v3 , because the first is what you are actually using here. The latter is now split into iOS and Android BTW.

You also need to add your link to your server key.

If it is local, it should be something like:

localhost/*

+5
source share

I think you should check referrers. This example is on the API console site:

 Example: *.example.com/*. *One URL or pattern per line.* 

Try including the referrer full name without using wildcards. Using wildcards seems a bit odd. More people are struggling with this, see this post. You can find a description of a possible whitelist configuration on the help page of the Google APIs console .

(You mentioned that your private key has the same sources as your company key. I wonder if this is possible, since in this case you can use different keys for the same application.)

+4
source share

For a moment I hit my head against the wall. Including a version number that is not used in this example, fixed it for me.

<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=YOURKEY">

^ Does this have a bit ?v=3.exp

+3
source share

In referrers we had * . The fix was to actually leave it blank, which means to allow everything.

+2
source share

Add v=3; in front of your key.

 maps.googleapis.com/maps/api/js?**v=3;**key={your key};sensor=false 
+2
source share

I had several messages from customers about problems with Google maps on their sites. I checked and received the "Wrong key" errors.

Strange, but Google used to issue keys with a space before and after the API key. In the past, when I left empty seats, the key broke. It was unpleasant to remember to leave these places.

Now I trim() my current API key (with or without spaces) before sending it to Google Maps, and it works.

+2
source share

If you are testing locally, be sure to add your local ip to the server key:

 xxx.xxx.xxx.xxx 

if you want api maps to be available throughout the domain, add this to your browser key:

 *.mydomain.com/* 

Hope this helps.

0
source share

I also receive an invalid key message, and after trawling all over the Internet I found what happened to my problem. This may affect others. This had nothing to do with the key.

I found that I had an error in the "initialize" function (in my case, the missing comma at the end of the line in mapOptions). This arose because I added a new (last) line and could not put a comma at the end of the previous one. A good argument is to always have a comma, even on the last line.

Now I can enable or disable the invalid key message by deleting / replacing this comma. I conclude that any error in the associated JS card may lead to its occurrence.

0
source share

Now adding a map from Google has become more problematic than before. On the page https://leafletjs.com/ you will find another more convenient library with maps.

0
source share

All Articles