DiamondJoe12
DiamondJoe12

Reputation: 1809

Python geocoder REQUEST DENIED even with API key?

I signed up for a google API key to geocode addresses. I'm attempting to use Python's geocoder.

g = geocoder.google('Mountain View, CA', key='puting my key here')

However, it's still giving me:

<[REQUEST_DENIED] Google - Geocode [empty]>

What's going on here?

Upvotes: 4

Views: 6214

Answers (4)

Seedless Mango
Seedless Mango

Reputation: 1

The previous responses were right. You needed to enable the billing in order to make requests. You can go to this website and enable billing. I think that's the only way you would be able to make requests. https://console.cloud.google.com/project/_/billing/enable

Upvotes: -1

Kriss N
Kriss N

Reputation: 11

the geodecode API requires to pay. Put your billing info then you can use it.

Upvotes: 1

Ryan
Ryan

Reputation: 483

You can get more information about the error by attempting to load your request in a browser. You can get the URL with g.url in the below example:

>>> import geocoder
>>> g = geocoder.google('Mountain View, CA', key='puting my key here')
>>> g.ok
False
>>> g
<[REQUEST_DENIED] Google - Geocode [empty]>
>>> g.url
'https://maps.googleapis.com/maps/api/geocode/json?address=Mountain+View%2C+CA&bounds=&components=&region=&language=&key=puting%20my%20key%20here'

When I copied that result into a browser window it was clear:

{
   "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"
}

In my case, @Tanaike was right: even though I recall enabling the new API key, I had not enabled 'billing' on my Google Cloud Project (https://console.cloud.google.com/project/_/billing/enable).

Upvotes: 2

Tanaike
Tanaike

Reputation: 201378

From the error message, I thought that Geocoding API might not be enabled at API console for the project retrieved the API key. Please confirm this. When the script is run after Geocoding API was enabled, the following response is returned.

<[OK] Google - Geocode [###]>

Note:

  • If you know the project ID, you can open the page for enabling the API at
    • https://console.cloud.google.com/apis/library/geocoding-backend.googleapis.com?project=project-id-#####
  • About pricing, please check https://cloud.google.com/maps-platform/pricing/.

References:

If this was not useful for your situation, I apologize.

Upvotes: 2

Related Questions