Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The key provided is not a valid Google API Key

I am getting error

Google has disabled use of the Maps API for this application. The provided key is not a valid Google API Key, or it is not authorized for the Google Maps Javascript API v3 on this site. If you are the owner of this application, you can learn about obtaining a valid key here: https://developers.google.com/maps/documentation/javascript/tutorial#Obtaining_Key

I have generated an API from api-console and using it for my local/local-host website but each time I am getting the above error. How can I show google maps on my localserver?

like image 473
coure2011 Avatar asked Jun 10 '12 05:06

coure2011


People also ask

How do I get an API key for Google Cloud API?

To get an API key: Go to the Google Cloud Console. Click the project drop-down and select or create the project for which you want to add an API key. Click the menu button and select APIs & Services > Credentials.

How do I restrict access to Google Maps API keys?

Go to the Google Maps Platform > Credentials page. Select the API key that you want to set a restriction on. The API key property page appears. To accept requests from the list of website that you supply, select HTTP referrers (web sites) from the list of Application restrictions.

Why is my Google API not working?

There is a clue in Google API’s error message – the API is fine, but the use and restrictions are incorrect. In your key restrictions, select the IP address (it may be IPv4 or IPv6) and Selected API: Places API. Sometimes Google will tell you which IP address to use (from what it sees making the request).

How can I Make my API key only accept signed requests?

To ensure that your API key only accepts signed requests: Go to the Google Maps Platform Quotas page in the Cloud Console. Click the project drop-down and select the same project you used when you created the API key for the Maps Static API. Click the APIs drop-down and select Maps Static API.


Video Answer


3 Answers

I have the similar problem as you today and I think I solved it.

First I am assuming that you have a google map api key already. I think what you need to do is to to go API Console - Google Code and click on API access on the left. You can see your api key and just below the key, Referers: shows your allowed referers. What you need to do is click Edit allowed referers... and then add

localhost/*

to allowed referers.

I am using a MAMP to host my html, and I monitor the request my browser sent to google for api and I get this header:enter image description here

showing Referer as localhost/*

It takes several minutes for Google to process after you changed your Referer but it works fine for me afterwords.

like image 127
Fei Avatar answered Oct 02 '22 06:10

Fei


The answer by @Fei helped me. The issue I ran into is including multiple referrals. The following worked well for me. Enter a return before adding each record (as opposed to a comma or another delimiter). enter image description here

like image 24
ter24 Avatar answered Oct 02 '22 07:10

ter24


don't know if this is the same problem but for me it turned out to be not the referrer. I changed the url for map.google.com to the url below and the referrer as either "any referrer allowed" or one of the whitelisted patterns https://developers.google.com/console/help/#whitelistingbyhost.

I Removed the version and the file params from the url (even if the version was 3 it was still going through a v2 authorization)

<script src="http://maps.google.com/maps?sensor=false&amp;key=${YOUR_KEY}" type="text/javascript"></script>

By what people say you would not need the key but could not get it working without it.

like image 26
ajeeshpu Avatar answered Oct 02 '22 06:10

ajeeshpu