Shane
Shane

Reputation: 165

INVALID_AUDIENCE error with Google OAuth 2.0 API

I am following this tutorial to get auth tokens.

I have both of my client_ids for web server and android device set up but I am getting an INVALID_AUDIENCE error. I believe this is because I have not generated and signed my APK, instead I am in development.

Is there something special I need to do to test the auth on my device via USB?

I'll go through how I set up my client_ids.

Web Server

This was easy all it needed was a URL.

Android

This one was a little harder. I generated that APK certificate (the .jks file). Then cd to the jdk/bin dir and ran

keytool -exportcert -alias occucard -keystore "C:\Users\Shane\AndroidAppKeys\Occucard/occucard.jks" -v -list

as the tutorial instructs. I think this may be the problem. Since its a development generated apk and not signed with the key.

Side Note: My scope token required for GoogleAuthUtils looks like:

"audience:server:client_id:" + SERVER_CLIENT_ID

Upvotes: 0

Views: 2773

Answers (1)

Shane
Shane

Reputation: 165

My solution was to create a third client_id with the debug.keystore SHA1 key. I ran the command

keytool -list -alias androiddebugkey -keystore "C:\Users\Shane\.android/debug.keystore" -storepass android -keypass android

This allowed me to use the client_id in development mode.

Upvotes: 2

Related Questions