2

I've set up 2 Client IDs for Android application in the GoogleDriveAPI console: the first for the release APK and the second for Debug purposes. Everything ok with the released app, but my issue is only related to the second Client ID. I'm getting this exception: com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAuthIOException

after the following lines:

Drive.Files.List request;
request = service.files().list();
String query = "mimeType='application/vnd.google-apps.folder' AND trashed=false AND title='" + title + "' AND '" + parentId + "' in parents";
request = request.setQ(query);
com.google.api.services.drive.model.FileList files = request.execute(); // <=I'm getting the exception here

I'm using ADT on windows, I've obtained the sha1 fingerprint for debug keystore from Windows->Preferences->Android->Build for the debug mode, but the Google Drive API authorization fails! Why? The (only) solution I've found is to use the "Release" Client ID also in Debug mode, with a custom fingerprint (and that actually works).

Marcus
  • 6,697
  • 11
  • 46
  • 89
  • I registered both of them in the developer's console. But I use only the 'release' even when debugging for another reason. Once (it might have been a temporary glitch in GooPlaySvcs), I could not get all the files/folders created with the debug when I switched to release. It was in the early GDAA days (March 2014), so it may work now. I would suggest to check if it works OK before you have to download and re-upload 2K files to your phone(as I had to). There is a way to set your environment to produce 'release' SHA1 even when debugging. I'll try to find it and will GIST it soon. – seanpj Feb 20 '15 at 20:53
  • Thank you. Yes, it's what I did, I've found it also here: http://stackoverflow.com/questions/15754060/how-to-set-a-custom-keystore-for-debugging-in-eclipse-for-android –  Feb 21 '15 at 04:48
  • and here: http://stackoverflow.com/a/14018541/4569980 –  Feb 21 '15 at 05:14
  • Finally I deleted the Debug Client ID (even if it was working fine) from the API console for security reasons –  Feb 21 '15 at 05:36
  • I fixed similar error by remove existing app, reinstall latest play store app, test over and over again of old apk and finally the existing development apk is working fine again without figure out the exact reason. – 林果皞 Feb 14 '17 at 14:10

1 Answers1

3

Try this: Take the *.apk file that isn't working (DEBUG.apk), I don't know what's your IDE, so I can't tell you where to find it, but it should be easy.

  1. Open the '*.apk' file in 7-zip or similar unzipper and find 'META-INF\CERT.RSA' file in the archive. Unzip it, for instance to your ...\desktop\
  2. Run 'keytool -printcert -file ...\desktop\CERT.RSA'.
  3. You should see the SHA1 of the APK file in question, compare it with the SHA1 you registered in the console. Double-check the package name as well. PackageName-SHA1 combination is what authorizes the app version with Google Drive.

I vaguely remember this happening to me after re-installing/upgrading my IDE or moving project to another machine (basically generating different debug SHA1 than I registered).

I know it is a long shot, but this is what I use when run into trouble.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
seanpj
  • 6,735
  • 2
  • 33
  • 54
  • My ide is the eclipse.exe in adt-bundle-windows-x86_64 Step 0: I've removed the custom debug keystore and I've found the apk in the bin folder. After following your steps 1 and 2, at your step3 I see the SHA1 (not RSA1) and it is equals to what I registered in the console In conclusion the field of the SHA1 debug fingerprint I entered was *correct* but I misspelled a letter in the other field of the package name :-( Btw, what is absurd is that now the app continue to be authorized even if I delete the Client IDs...I hope it's just a lag! I reinserted them anyway –  Feb 16 '15 at 05:35
  • I fixed the SHA1 - RSA1 typo in the answer, thanks. BTW, the mere fact that I know the answer suggests that you're not the only one who run into such roadblock :-) – seanpj Feb 16 '15 at 11:17