DenisCarriere / geocoder

:earth_asia: Python Geocoder
http://geocoder.readthedocs.org
MIT License
1.63k stars 287 forks source link

<[REQUEST_DENIED] Google - Geocode [empty]> #440

Open joebling opened 3 years ago

joebling commented 3 years ago

when i have installed geocoder, run the examples in readme.md, it shows:

g = geocoder.google([-6.1166283, 106.88594], method='reverse') g <[REQUEST_DENIED] Google - Reverse [empty]>

Kalebu commented 3 years ago

I'm having the same error with normal geocoding

>>> g = geocoder.google('Mbezi, Tanzania')
>>> g
<[REQUEST_DENIED] Google - Geocode [empty]>
gpsugy commented 3 years ago

Not sure when this got implemented, but I noticed we now need to include the third parameter key=[YOUR_API_KEY]. For example, g = geocoder([-6.1166283, 106.88594], method='reverse', [YOUR_API_KEY])

If that still does not work, you likely need to enable Billing for the project: https://console.cloud.google.com/billing

BigBaaadBob commented 3 years ago

I have the same problem. I have billing set up and the python googlemaps code works with the apikey, but the geocoder doesn't:

$ python
Python 3.9.5 (default, May 18 2021, 14:42:02) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import googlemaps
>>> import os
>>> gmaps = googlemaps.Client(key=os.getenv('GOOGLE_API_KEY'))
>>> tz = gmaps.timezone((45.15, -75.14))
>>> tz
{'dstOffset': 3600, 'rawOffset': -18000, 'status': 'OK', 'timeZoneId': 'America/Toronto', 'timeZoneName': 'Eastern Daylight Time'}
>>> quit()

$ geocode '45.15, -75.14' --provider google --method timezone
{"raw": {"errorMessage": "You must use an API key to authenticate each request to Google Maps Platform APIs. For additional information, please refer to http://g.co/dev/maps-no-account", "status": "REQUEST_DENIED"}, "status": "ERROR - No results found", "ok": false}

FWIW, I use the environment variable in the above, but I get the same result if I use the key parameter.