Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 507
user2525034 Avatar asked Jun 06 '26 23:06

user2525034


2 Answers

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.

like image 154
Tomas Avatar answered Jun 10 '26 18:06

Tomas


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.
like image 39
geocodezip Avatar answered Jun 10 '26 18:06

geocodezip



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!