Google Endpoints - Android GoogleAuthIOException Tic Tac Toe - Removed clientIds

爱⌒轻易说出口 提交于 2019-12-03 20:40:55

The error is most likely due to the authorization not happening between your Android application and the Cloud Endpoints API.

Since I do not have full access to your actual Endpoint API annotations and the Android code, I would suggest that you look at the following points closely:

  • Ensure that you have annotated your Cloud Endpoints API correctly with the clientIds and audiences. The Android Audience value is the same as that of the Web Client Id.

  • Make sure you have deployed the updated API and regenerated the Endpoints API sources for inclusion in your Android application.

  • Finally, in your Androids source code, you must build an instance of the GoogleAccountCredential, using the GoogleAccountCredential.usingAudience(...) and then use this credential object while making a call to the endpoint API. For e.g. the Endpoint builder takes a HTTP Transport, GSON Factory and the Credential. Do not leave the last parameter (i.e. Credential) as empty.

I was also getting a similar GoogleAuthIOException exception:

com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAuthIOException
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:286)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:859)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:410)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:343)
at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:460)
at com.example.MainActivity$ListPartiesTask.doInBackground(MainActivity.java:188)
at com.example.MainActivity$ListPartiesTask.doInBackground(MainActivity.java:178)
at android.os.AsyncTask$2.call(AsyncTask.java:287)
at java.util.concurrent.FutureTask.run(FutureTask.java:234)
at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
at java.lang.Thread.run(Thread.java:841)
Caused by: com.google.android.gms.auth.GoogleAuthException: Unknown
at com.google.android.gms.auth.GoogleAuthUtil.zzb(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.zza(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at com.google.android.gms.auth.GoogleAuthUtil.getToken(Unknown Source)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential.getToken(GoogleAccountCredential.java:255)
at com.google.api.client.googleapis.extensions.android.gms.auth.GoogleAccountCredential$RequestHandler.intercept(GoogleAccountCredential.java:279)
... 12 more

Turns out I needed to create a Client ID with the sha1 fingerprint of the debug version of the app (I had already created one for the signed version of the app, but if you haven't done that you'll need to do that too).

You can get the fingerprint with the following command (on a Mac, address of debug.keystore might be different on other systems):

keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android -keypass android

If you need to get the fingerprint for your release key you can do this:

keytool -list -v -keystore /PATH/TO/YOUR/release-key.jks -alias RELEASE_KEY_ALIAS
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!