63

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?

BenMorel
  • 34,448
  • 50
  • 182
  • 322
cs0815
  • 16,751
  • 45
  • 136
  • 299

17 Answers17

79

Until the end of 2014, a common source of this error was omitting the mandatory sensor parameter from the request, as below. However since then this is no longer required:

The sensor Parameter

The Google Maps API previously required that you include the sensor parameter to indicate whether your application used a sensor to determine the user's location. This parameter is no longer required.


Did you specify the sensor parameter on the request?

"REQUEST_DENIED" indicates that your request was denied, generally because of lack of a sensor parameter.

sensor (required) — Indicates whether or not the geocoding request comes from a device with a location sensor. This value must be either true or false

Community
  • 1
  • 1
Rup
  • 33,765
  • 9
  • 83
  • 112
  • This also caught me out. I assumed they'll put all the required parameters at the top of the list! – Jrgns Apr 02 '11 at 09:54
  • 4
    What is the difference between providing `sensor=true` vs `sensor=false` ? I mean so *what* if the calling computer is able to use sensor? When I try `sensor=false`, I get **exactly** the same thing as when I try `sensor=true`. So why not simply use `sensor=random(true/false)` ? – Pacerier Jan 15 '12 at 02:37
  • 4
    @Pacerier: it's a statistics thing. It *may* also have implications for any licensing fees which Google pays. But Google are highly unlikely to say why the difference is necessary, especially if it's commercial. – Andrew Leach Mar 15 '12 at 13:49
  • 3
    We see this error occasionally, even _with_ the `sensor` param supplied. I don't believe it is a throttling issue, since we are waiting at least a full second between requests, nor do we approach anywhere near the 2500 daily request limit. Still not sure why we see this occasionally, since repeating the query works for us later... Perhaps just usual "hiccups" coming from them? – Funka Feb 01 '13 at 22:55
  • I noticed that is not necessary to send the API Key, I really don't get this, The Docs clearly states that a Key is needed, it also says that Geo-coding is to be used with Maps, and that otherwise is prohibited.... However, im trying it out and it works fine without the API Key – Gabriel Matusevich May 26 '14 at 04:40
  • @Gabriel If that works fine then great, but I suspect you'll get a much lower daily request limit without a key. – Rup May 27 '14 at 06:33
  • As of today, the `sensor` parameter is no longer required. Please refer [here](https://developers.google.com/maps/documentation/geocoding/#Sensor). – Koh Jan 04 '15 at 03:05
  • @Koh Thanks, edited that in. I'm not sure what else to do with the answer now it's out-of-date, though. – Rup Jan 04 '15 at 13:01
19

Remove the API key parameter and its value.

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

Lauren Rutledge
  • 1,195
  • 5
  • 18
  • 27
PARTH DAVE
  • 225
  • 2
  • 2
  • 4
    +1 Very frustrating that this worked. The API key actually identifies my app... which allows Google to paint a very specific picture of my app and users. Why would Google reject such identifying information in favor of an anonymous request?? – Ryan Wheale Apr 23 '13 at 20:05
  • Thanks a lot. This actually worked. Totally agree with @RyanWheale . This is ridiculous. – KD. May 14 '13 at 07:08
  • 3
    Does anyone have a reference as to why you need to remove the API key? Does this mean that particular API is governed by the "Business" part, and I need to register with Google for that to get it to work? (+1 BTW!). – Peter K. Jan 28 '14 at 13:08
  • The key may have a greater quota but is restricted to specific domain. Check that the key is for the domain you use. – Maor Feb 19 '14 at 21:46
  • 1
    you are in violation of TOS if you do this in a business application. Don't do it. – Taugenichts Sep 10 '18 at 21:38
18

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.

shimshon
  • 345
  • 3
  • 9
14

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

J.T. Taylor
  • 4,147
  • 1
  • 23
  • 23
14

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.

  • 2
    Yes, it the Geocoding has to be enabled. Took me 4 hours to realize that was the problem. – RationalRabbit Mar 28 '19 at 01:01
  • How to activate this? – Payal May 26 '20 at 15:08
  • @Paypal, Go to the Dashboard of your project and scroll down to see your activated APIs. If "Geocoding API" is not activated, click on "ENABLE APIs & SERVICES" at the top, search for "Maps" in the left pane index and select "Geocoding API". – Mario Vázquez Jun 10 '20 at 11:14
10

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...

Alex
  • 101
  • 1
  • 2
7

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.

user3709875
  • 69
  • 1
  • 2
5

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).

Koen Cornelis
  • 192
  • 2
  • 13
  • In Drupal 8, I was able to resolve with my subdomain. I'm using geocoder module and in /admin/config/system/geocoder, I checked box "use SSL" under googlemaps setting (hadn't needed to do this when testing locally) – vrwired Oct 08 '18 at 17:43
4

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.

Abbas Uddin
  • 181
  • 1
  • 6
4

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

3

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.

Luke Alderton
  • 3,198
  • 1
  • 23
  • 34
3

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.

Emilio Venegas
  • 546
  • 5
  • 22
  • I have referrers set, using JS API and Geocoding and I don't have that problem. – RationalRabbit Mar 28 '19 at 00:59
  • Huh, maybe Google changed the API now but this was true when I posted it – Emilio Venegas Mar 28 '19 at 18:26
  • Geocoder/JS: I have a js script I wrote some 5 or 6 years ago (right after v3 came our) that has been working fine on numerous sites. After setting with keys, I was getting a non-specific error and discovered the problem was in the formatting of the Latitude/Longitude. I was using the variable produced by results[0].geometry.location, which came out as, for instance, (-34.397, 150.644), which I used in the query string. NO LONGER ACCEPTABLE. I had to convert that variable value to a string and remove the parenthesis. – RationalRabbit Mar 30 '19 at 00:11
  • Sounds like we're just talking about different issues. In my case, I had a script using a key with referrer restrictions and was getting a REQUEST_DENIED error. I removed the referrer without touching the script and that fixed it. – Emilio Venegas Apr 01 '19 at 19:35
  • 1
    Yes, different issues. I just thought I would throw that in there because you said "maybe Google changed" and this was a good example of a completely unexpected and apparently undocumented change that had me scratching my head for hours. Sorry for any confusion. My first answer was the actual response to your statement. – RationalRabbit Apr 01 '19 at 23:19
2

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 ...

Horst Schmid
  • 194
  • 1
  • 4
2

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"
}
TheMisir
  • 4,083
  • 1
  • 27
  • 37
0

In my case it was that I didn't enabled Billing on Google Cloud Console. first query it on a Browser or Postman.

enter image description here

Negus Nati
  • 13
  • 2
-1

I created another Credential(New API) only for Geocoding, with "Key restrictions" 'None' and "API restrictions" 'Restrict key'

Selected APIs:

Directions API Geocoding API Geolocation API Maps JavaScript API Places API

and then it's worked.

-2

I just ENABLED my geocoding API, geolocation API and places API on my google cloud platform (where I had generated my API key I was using) and it worked.