[google-app-engine] Google Geocoding API - REQUEST_DENIED

Apparently I do not need a 'Maps API key' to use the 'Google Geocoding API' according to:

http://code.google.com/apis/maps/documentation/geocoding/index.html

However, I obtain this:

{
  "status": "REQUEST_DENIED",
  "results": [ ]
}

Does this mean that my IP is blocked? What can I do to overcome this?

This question is related to google-app-engine google-maps-api-3

The answer is


For anyone struggling with this issue, I just found out that the Geocoding API can't be used with API keys that have referrer restrictions. Just remove all your referrer restrictions and you should be good.

If you're using any other APIs that do allow keys with referrer restrictions (like the Maps JS API), it's probably best to create a 2nd key with no restrictions to use exclusively for geocoding, because other APIs might display your key publicly and someone else could start using it on their own site.


If none of given solutions fixed the error, the issue probably about Google Cloud Billing settings. You must enable Billing on the Google Cloud Project at billing/enable.

Learn more

{
    "error_message" : "You must enable Billing on the Google Cloud Project at https://console.cloud.google.com/project/_/billing/enable Learn more at https://developers.google.com/maps/gmp-get-started",
    "results" : [],
    "status" : "REQUEST_DENIED"
}

Remove the API key parameter and its value.

eg. https://maps.googleapis.com/maps/api/geocode/json?address=[YOUR ADDRESS]&sensor=true


Google is returning a very useful error message, which helps to correct the issue!

Dim Request         As New XMLHTTP30
Dim Results         As New DOMDocument30
Dim StatusNode      As IXMLDOMNode
Request.Open "GET", "https://maps.googleapis.com/maps/api/geocode/xml?" _
  & "&address=xxx", False
Request.Send
Results.LoadXML Request.responseText
Set StatusNode = Results.SelectSingleNode("//status")
Select Case UCase(StatusNode.Text)
    Case "REQUEST_DENIED"
          Debug.Print StatusNode.NextSibling.nodeTypedValue
    ... 

Error Message Examples

Message 1: Requests to this API must be over SSL. Load the API with "https://" instead of "http://".

Message 2: Server denied the request: You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please ...


If you just copy&paste the example URL that Google gives in their website http://maps.google.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true_or_false it will fail because of the wrong parameter of the sensor. You should change it to true or false and not the one that they wrote. Maybe is the error that you have had, like it happened to me...


It's suck Google don't let you that your service is not enabled by this account. Try to enable it first. Go here https://console.developers.google.com/project and create a new project with place service activated this may solve your problem.


I found that in my case, calling to the service without secure protocol (meaning: http), after adding the key=API_KEY, cause this issue. Changing to https solved it.


As you say, this can mean that your IP address has been blocked. I'd make sure that you specify the key parameter on the query string for the Geocoding API request.

https://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=Placename&key=XXxxxXXxXxxxxXXxx

Also make sure that if you've set up IP Address Restrictions within the Developer Console, you've allowed the correct IP address, just click the project within the list and you'll see the allowed IPs.

Example of project list in Google Developer Console

If you're still running into issues, you might want to look into printing out the values of the status and error_message elements from the response from Google, you'll see something like this:

REQUEST_DENIED - This IP, site or mobile application is not authorized to use this API key. Request received from IP address 123.4.5.678, with empty referer

If it doesn't mention an IP address restriction, it may well give you enough information about the problem to Google a fix.


I've noticed that you also get REQUEST_DENIED for some addresses if you don't properly URL encode your address. For example, in

123 Main St #B, Mytown, CA 94110

the '#' character needs to be encoded as %23


I had this problem and I realized that I was assuming that Geocoding came with the JS maps API. However, it is a separate API which I hadn't enabled in the cloud console. Enabling it fixed it right away.


For those who are looking this page in 2017 or beyond, like me

Sensor is not required anymore, I tried and got the error:

SensorNotRequired

I just needed to activate my Google Maps Geocoding API, that seems to be necessary nowadays.

Hope it helps someone like me.


 https://maps.googleapis.com/maps/api/geocode/json?address=36,+Langford+Rd,+Bheemanna+Garden,+Langford+Gardens,+Bengaluru,+Karnataka+560027&key=<apikey>

with direction services enabled worked for me


I got this problem as well using the drupal 7 Location module. Autofilling all empty locations resulted in this error. Executing one of the requests to the location api manually resulted in this error in the returned JSON:

"Browser API keys cannot have referer restrictions when used with this API."

Resolving the problem then was easy: create a new key without any restrictions and use it only for Geocoding.

Note for those new to google api keys: by restrictions they mean limiting requests using an api key to specific domains / subdomains. (eg. only request from http://yourdomain.com are allowed).


If you not have configured a billing account with your credit card, the API do not work. The Google is now very hungry for money and not open more your products "free". Obviously that him offer a free limited access number of consults and over this acces, the billing is very high.

https://cloud.google.com/maps-platform/pricing