Open akaszynski opened 5 years ago
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.
literally: geocoder.google(QUERY, key=KEYGOESHERE)
this is already supported, no?
https://github.com/DenisCarriere/geocoder/blob/master/geocoder/google.py#L192
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.
GOOGLE_API_KEY = os.environ['GOOGLE_API_KEY']
Tested with Django, working well here
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]>
Would be nice if these information was somewhere in the install guide, because otherwise the instal guide doesn't make sense.
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!
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.
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=®ion=&language=&key=GOOGLE_API_KEY
Looks like google just started requiring an API key. A more informative error would be great when requesting from Google.