Reputation: 473
I am getting a GoogleAuthException: Unknown error
, while doing a GoogleAuthUtil.getToken
.
Just before the exception I see
GLSUser: GLS error: INVALID_AUDIENCE <email> audience:server:client_id:xxx.apps.googleusercontent.com
I have set the SHA1 from my release key , the package name, to the google api project. (Which by the way is being used successfully for GCM. )
Upvotes: 18
Views: 15487
Reputation: 910
In the interest of documenting my issue,
I had the same INVALID_AUDIENCE error come back from a Google sign-in through an AWS Mobile Hub generated sample app. A few things to check,
Like Tim Bray notes aboves, make your client id a valid web client id (not Android). But also have an android client id that has both the proper SHA-1 Fingerprint (found in debug.keystore which Android Studio uses to sign debug builds when you click Run) and package name.
NOTE: The package name listed in the AndroidManifest.xml is not always the actual package name. To find the definitive package name, go to the build.gradle file and see the applicationId field. Be sure to input the right package name in the Developers Console when you configure the Android Client Id.
Upvotes: 1
Reputation: 234
Also you have to set up oAuth authorization screen in your Google API Console.
That was why I got this error
Upvotes: 0
Reputation: 1514
Solve this by deleting your debug.keystore found in your .android folder, then run the new project again to generate a new debug.keystore file. Then finally generate a new SHA-1 signing-certificate for Google API.
Upvotes: 0
Reputation: 28199
Happened to one on my team although it worked ok on my device.
It turned out to be because of a different debug.keystore
on our eclipse installations.
To solve it we've copied the company's debug.keystore
file to ~/.android/
(this is the dir on a mac, it's different on linux and windows)
Upvotes: 0
Reputation: 1663
Looks like that should work; here's the scope-init code from my app which does work.
private static final String SCOPE = "audience:server:client_id:" + SERVER_CLIENT_ID;
So it smells to me like there's a problem with the client id. Remember that
It's the client ID from #3 that goes after ...:client_id:
Upvotes: 16