CUTR-at-USF / OpenTripPlanner-for-Android

An Android app for multi-modal trip planning and navigation using any OpenTripPlanner server.
Other
129 stars 91 forks source link

GooglePlaces key problem #325

Closed vreixo closed 10 years ago

vreixo commented 10 years ago

GooglePlaces geocoding is no longer working and I suspect that is related to a license problem.

This is the log error: "This IP, site or mobile application is not authorized to use this API key."

barbeau commented 10 years ago

@vreixo Is this for version currently on Google Play?

vreixo commented 10 years ago

The message is from the development version, but I have checked the Play Store version and always fails to get results. I have switched to mobile data to see if it's an issue with my IP, but it doesn't help.

2014-08-20 0:03 GMT+02:00 Sean Barbeau notifications@github.com:

@vreixo https://github.com/vreixo Is this for version currently on Google Play?

— Reply to this email directly or view it on GitHub https://github.com/CUTR-at-USF/OpenTripPlanner-for-Android/issues/325#issuecomment-52705928 .

barbeau commented 10 years ago

The Google Places API key will only work for APKs signed with certificates that I whitelist in my Google API console. If you changed development machines, then your current dev cert isn't whitelisted and it will fail for you. If you send me your current cert. SHA1 (see https://developers.google.com/+/quickstart/android#step_1_enable_the_google_api for how to get it) I'll verify that its whitelisted.

However, the version on Google Play should never fail, since its signed with a production certificate that never changes. If that is failing with the same error, then something else is going on.

vreixo commented 10 years ago

@barbeau I have tested it in another device, with play store version, and still does not work.

Does it work for you?

To be sure that only Google Places results are obtained:

  1. Change used geocoder to Google Places.
  2. Go to submenu "Advanced" of geocoding and disable "Prefer Android geocoder".
barbeau commented 10 years ago

Hmmm, you're right, version on Play store doesn't work for me either. I'll see if I can figure out why tomorrow. On Aug 19, 2014 8:47 PM, "Vreixo González Caneda" notifications@github.com wrote:

@barbeau https://github.com/barbeau I have tested it in another device, with play store version, and still does not work.

Does it work for you?

To be sure that only Google Places results are obtained:

  1. Change used geocoder to Google Places.
  2. Go to submenu "Advanced" of geocoding and disable "Prefer Android geocoder".

— Reply to this email directly or view it on GitHub https://github.com/CUTR-at-USF/OpenTripPlanner-for-Android/issues/325#issuecomment-52721248 .

barbeau commented 10 years ago

In the version on Google Play, I'm seeing the same error: edu.usf.cutr.opentripplanner.android V/OTP﹕ { "error_message" : "This IP, site or mobile application is not authorized to use this API key.", "html_attributions" : [], "results" : [], "status" : "REQUEST_DENIED"}

barbeau commented 10 years ago

Ah - it looks like a key (maybe yours?) was accidentally checked into Github: https://github.com/CUTR-at-USF/OpenTripPlanner-for-Android/blob/master/opentripplanner-android/src/main/res/raw/googleplaceskey.txt

I'll fix this shortly by changing the .gitignore.

barbeau commented 10 years ago

Actually, thinking more, we can't ignore the googleplaceskey.txt file since the project wouldn't build on Travis. I'll just bundle the production key, since its restricted in use based on the cert that is used to sign the app.

barbeau commented 10 years ago

Well, I was wrong - I was confusing Places API key with Maps v2 API key (Google doesn't label which key is which in the API console). Places API key can't be restricted by Android package name and signing cert, it can only be restricted by IP address (which doesn't help us on mobile). Looking at Git history, I accidentally committed the wrong key a while back when changing to Android Studio. I'm going to add the correct Places key for production now, so we don't have key problems again in the future. If there is abuse of the key (unlikely), we'll just generate a new one.

barbeau commented 10 years ago

@vreixo BTW, the autocomplete is very nice! :) Good job on that.