user2525034
user2525034

Reputation: 43

Provided key is not a valid Google API key

I am new to google map api. I copied the Hello_World.html from google maps javascript v3 getting started. But I always get the error message: the provided key is not a valid google api key.

I tried a few things but none of them worked. The following is what I did:

  1. I edited the allowed referrers to mysite.com/* and localhost/*. But the error message is still there.
  2. I tried a method someone suggested, which adds javascript version number: change src="https://maps.googleapis.com/maps/api/js?key={XXX....X}&sensor=true" to src="https://maps.googleapis.com/maps/api/js?v=3.6key={XXX....X}&sensor=true", even so, the error message is still there.

Can someone give me any suggestions?

Upvotes: 3

Views: 3803

Answers (3)

VeYroN
VeYroN

Reputation: 760

I had this problem. The solution is:

  1. Go to https://code.google.com/apis/console -> api access
  2. Click "Key for browser apps".
  3. The example says to enter *.example.com/* but it doesn't work for me. I had to enter (one per line):

    example.com   
    *.example.com
    *.example.com/*
    example.com/*
    

Hope this helps

Upvotes: 1

geocodezip
geocodezip

Reputation: 161324

You don't need a key, it should work without it. If you provided the key you are using (it isn't secret and can't be used on domains that you don't allow), we could tell if it is at least the correct format.

This

src="https://maps.googleapis.com/maps/api/js?v=3.6key={XXX....X}&sensor=true

is incorrect.

  1. it is missing an & between the v=3.6 and "key".
  2. version 3.6 is no longer available, that will result in the "frozen version", currently version 3.11.

Upvotes: 2

Tomas
Tomas

Reputation: 59435

You do not need a key for Google Maps API v3, see the documentation. Your API v2 key will not work. You will only need key for API v3 in case you want some additional features (very high traffic site, additional statistics etc.). But this is a very rare case.

Upvotes: 2

Related Questions