Google maps API V2 stopped working

284 views
Skip to first unread message

Craig Blaszczyk

unread,
Mar 11, 2013, 6:21:04 AM3/11/13
to ge...@googlegroups.com
Hi guys,

Maps API V2 has stopped working for me today, citing a 'bad api key' error:

>>> g = Google()
>>> g.geocode('an address')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/craig/.virtualenvs/aaa/local/lib/python2.7/site-packages/geopy/geocoders/google.py", line 81, in geocode
    return self.geocode_url(url, exactly_one)
  File "/home/craig/.virtualenvs/aaa/local/lib/python2.7/site-packages/geopy/geocoders/google.py", line 88, in geocode_url
    return dispatch(page, exactly_one)
  File "/home/craig/.virtualenvs/aaa/local/lib/python2.7/site-packages/geopy/geocoders/google.py", line 107, in parse_xml
    self.check_status_code(status_code)
  File "/home/craig/.virtualenvs/aaa/local/lib/python2.7/site-packages/geopy/geocoders/google.py", line 168, in check_status_code
    raise GBadKeyError("The api_key is either invalid or does not match the domain for which it was given.")
geopy.geocoders.google.GBadKeyError: The api_key is either invalid or does not match the domain for which it was given.

I've also tried using the my API key (from the Google API Console):

>>> g = Google(api_key='AIzaSyArPsABms_FlecypnwTJZ5qZbacefefcL1E')
>>> g.geocode('an address')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/craig/.virtualenvs/aaa/local/lib/python2.7/site-packages/geopy/geocoders/google.py", line 81, in geocode
    return self.geocode_url(url, exactly_one)
  File "/home/craig/.virtualenvs/aaa/local/lib/python2.7/site-packages/geopy/geocoders/google.py", line 88, in geocode_url
    return dispatch(page, exactly_one)
  File "/home/craig/.virtualenvs/aaa/local/lib/python2.7/site-packages/geopy/geocoders/google.py", line 107, in parse_xml
    self.check_status_code(status_code)
  File "/home/craig/.virtualenvs/aaa/local/lib/python2.7/site-packages/geopy/geocoders/google.py", line 168, in check_status_code
    raise GBadKeyError("The api_key is either invalid or does not match the domain for which it was given.")
geopy.geocoders.google.GBadKeyError: The api_key is either invalid or does not match the domain for which it was given.

I've also tried using a domain, with the same results. I'm based in the UK, so I did:

>>> g = Google(api_key='AIzaSyArPsABms_FlecypnwTJZ5qZbacefefcL1E', domain='maps.google.co.uk')
>>> g.geocode('an address')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/craig/.virtualenvs/aaa/local/lib/python2.7/site-packages/geopy/geocoders/google.py", line 81, in geocode
    return self.geocode_url(url, exactly_one)
  File "/home/craig/.virtualenvs/aaa/local/lib/python2.7/site-packages/geopy/geocoders/google.py", line 88, in geocode_url
    return dispatch(page, exactly_one)
  File "/home/craig/.virtualenvs/aaa/local/lib/python2.7/site-packages/geopy/geocoders/google.py", line 107, in parse_xml
    self.check_status_code(status_code)
  File "/home/craig/.virtualenvs/aaa/local/lib/python2.7/site-packages/geopy/geocoders/google.py", line 168, in check_status_code
    raise GBadKeyError("The api_key is either invalid or does not match the domain for which it was given.")
geopy.geocoders.google.GBadKeyError: The api_key is either invalid or does not match the domain for which it was given.

Do you guys have any idea what's causing this?


Regis Vincent

unread,
Mar 12, 2013, 5:50:37 PM3/12/13
to ge...@googlegroups.com
Same behavior here. It was working yesterday. Today no luck. Anyone has an idea why?

starenka .

unread,
Mar 12, 2013, 5:55:48 PM3/12/13
to ge...@googlegroups.com

I guess they're phasing v2 out. Happened to me w/ simple http calls (no geopy) last week. As Craig here, I've first tried to generate new keys, but they didnt work.

---
print 'aknerats'[::-1]

--
You received this message because you are subscribed to the Google Groups "geopy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geopy+un...@googlegroups.com.
To post to this group, send email to ge...@googlegroups.com.
Visit this group at http://groups.google.com/group/geopy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Mike Tigas

unread,
Mar 12, 2013, 6:46:56 PM3/12/13
to ge...@googlegroups.com
Hi all,

Looks like despite the claims on
http://googlegeodevelopers.blogspot.com/2013/03/an-update-on-geocoding-api-v2.html
that the API would stick around for another six months, there looks to
be some breakage (possibly due to the URLs used by Geopy).

I've rushed out a version bump that includes a new geocoder at
"geocoders.googlev3.GoogleV3" (old one is "geocoders.google.Google").

https://github.com/geopy/geopy/blob/a1dfe0f072/geopy/geocoders/googlev3.py

Upgrading should be relatively simple if you are just using this for
basic lat/lon functionality.

1. Upgrade to geopy 0.95 ("pip install geopy==0.95" or manually do it:
https://pypi.python.org/pypi/geopy/0.95 )
2. Update code to use the new geocoder:

Replace any "Google(...)" geocoder references with "GoogleV3()".
You do not need an API key. (If you are a Google Maps for Business
paid user, you'll need "client_id" and "secret_key" -- please see
http://goo.gl/somDT )
Alternate domain names (i.e. "maps.google.co.uk") may no longer work.

Please report any issues or weirdness at
https://code.google.com/p/geopy/issues/detail?id=34 .
Reply all
Reply to author
Forward
0 new messages