geocoder icon indicating copy to clipboard operation
geocoder copied to clipboard

Google Requires API KEY

Open akaszynski opened this issue 6 years ago • 9 comments

Looks like google just started requiring an API key. A more informative error would be great when requesting from Google.

akaszynski avatar Mar 14 '19 18:03 akaszynski

Actually status looks fine:

>>> g = geocoder.google('Zoo Hamburg')
>>> g.ok
False
>>> g.status_code
200
>>> g.response
<Response [200]>
>>> g.status
u'REQUEST_DENIED'

But I don't find any info how to handle with API_KEY - where should it be put to be include to calls?


Update

OK, I answer myself with this: https://geocoder.readthedocs.io/providers/Google.html#environment-variables

But It will be nice to have something like envs settings in package.

dk-WZFinTech avatar Mar 25 '19 12:03 dk-WZFinTech

literally: geocoder.google(QUERY, key=KEYGOESHERE)

this is already supported, no?

https://github.com/DenisCarriere/geocoder/blob/master/geocoder/google.py#L192

gordol avatar Jul 08 '19 23:07 gordol

In [2]: import os                                                                                                                               

In [3]: os.environ["GOOGLE_API_KEY"] = "MY_API_KEY"                                                                

In [4]: import geocoder                                                                                                                         

In [5]: g = geocoder.google('Mountain View, CA')                                                                                                

In [6]: g                                                                                                                                       
Out[6]: <[REQUEST_DENIED] Google - Geocode [empty]>

In [7]: g = geocoder.google('Mountain View, CA', key="MY_API_KEY")                                                 

In [8]: g                                                                                                                                       
Out[8]: <[REQUEST_DENIED] Google - Geocode [empty]>

This is not working for me. Neither the environmental option, nor via key parameter.

FelixBuehler avatar Jul 16 '19 08:07 FelixBuehler

GOOGLE_API_KEY = os.environ['GOOGLE_API_KEY']

Tested with Django, working well here

AnthonyFillionMaillet avatar Jul 17 '19 13:07 AnthonyFillionMaillet

still not working for me. that's how it looks like for me:

import os
import geocoder

os.environ["GOOGLE_API_KEY"] = "xyz"       
GOOGLE_API_KEY = os.environ['GOOGLE_API_KEY']

g = geocoder.google('Mountain View, CA', key=GOOGLE_API_KEY)              
print(g)

<[REQUEST_DENIED] Google - Geocode [empty]>

FelixBuehler avatar Jul 19 '19 13:07 FelixBuehler

Would be nice if these information was somewhere in the install guide, because otherwise the instal guide doesn't make sense.

froggie901 avatar Jan 24 '20 23:01 froggie901

I ended up here because I didn't find it in the docs. "Providers" is right down the bottom of the page and not in the sidebar TOC. I didn't even spot there were more docs beyond the initial page.

The docs should mention much higher up the page that api keys might be needed and provider specific info is available.

EDIT - oh and better error messages!

andybak avatar Apr 17 '20 11:04 andybak

still not working for me. that's how it looks like for me:

import os
import geocoder

os.environ["GOOGLE_API_KEY"] = "xyz"       
GOOGLE_API_KEY = os.environ['GOOGLE_API_KEY']

g = geocoder.google('Mountain View, CA', key=GOOGLE_API_KEY)              
print(g)

<[REQUEST_DENIED] Google - Geocode [empty]>

Maybe you need to enable billing on your google dev account.

LuiCotias avatar Apr 30 '20 19:04 LuiCotias

I have same problem, but calling direct works. https://maps.googleapis.com/maps/api/geocode/json?address=21+RUA+JAIME+BENEVOLO+6050080+CENTRO+Fortaleza+CE+brasil&bounds=&components=&region=&language=&key=GOOGLE_API_KEY

israelins85 avatar Nov 11 '21 14:11 israelins85