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?
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 [###]>
https://console.cloud.google.com/apis/library/geocoding-backend.googleapis.com?project=project-id-#####
If this was not useful for your situation, I apologize.
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=®ion=&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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With