There are a couple of questions about this vague error code already, but none have solved this issue for me, so I'll try again. First, here is the boilerplate code for signing in.
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestServerAuthCode("web app client ID copied from Dev API Console", false)
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this).enableAutoManage(this, this).addApi(Auth
.GOOGLE_SIGN_IN_API, gso).build();
Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
startActivityForResult(signInIntent, RC_SIGN_IN);
With this code, I get a dialog and can select the appropriate user account. Yay! However, I then get a canceled code in onActivityResult, so I check logcat and notice the error message in the title. Then I search for other people with this issue, but haven't been able to figure out what the issue is in my case.
So let's check off common issues from other posts.
For searchability, right after the logcat error message in the title, I get the following logcat print.
You have wrong OAuth2 related configurations, please check. Detailed error: INVALID_AUDIENCE
Your Web Client ID has to be generated in the same user account as Firebase, not your Play Store account. In my case, the two accounts are separate, and Google throws this error instead of linking the information properly. My Firebase account is linked to my Play Store account but that apparently doesn't mean the web client ID will be shared. I tried some other solutions such as linking the API Manager accounts, and that didn't work either. You must create the Web Client ID inside the same project Firebase uses in the API Manager account that is the same as your Firebase account.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With