Reputation: 1809
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
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
Reputation: 11
the geodecode API requires to pay. Put your billing info then you can use it.
Upvotes: 1
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=®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).
Upvotes: 2
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 [###]>
https://console.cloud.google.com/apis/library/geocoding-backend.googleapis.com?project=project-id-#####
If this was not useful for your situation, I apologize.
Upvotes: 2