This exception code means configuration problems with your app. I was having the same problem, and it was solved, for me, this way (in my case, I wanted firebase authentication with google sign in mechanism):
- I used a google automatically generated web client id instead of the one I had created (I didn't even ask google to generate it - it was really automatic)
- I updated my JSON firebase file in my android project (it's probably not necessary but I was running out of options)
An observation that may be helpful:
- If you have a line like this...
Task<GoogleSignInAccount> task = GoogleSignIn.getSignedInAccountFromIntent(data);
handleSignInResult(task);
... probably you need Android auth
I will copy the important part of my code (it's working and written in Java), but I think, by your exception message, that there is nothing wrong with your code.
void onCreate(...) {
firebaseAuth = FirebaseAuth.getInstance();
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.web_server_client_id))
.requestEmail()
.build();
FirebaseUser currentUser = firebaseAuth.getCurrentUser();
firebaseAuthUpdateUI(currentUser);
mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
findViewById(getLoginButtonId()).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
signIn();
}
});
}
protected void signIn(){
Intent signInIntent = mGoogleSignInClient.getSignInIntent();
startActivityForResult(signInIntent, RC_SIGN_IN);
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == RC_SIGN_IN) {
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
if (result.isSuccess()) {
// Google Sign In was successful, authenticate with Firebase
GoogleSignInAccount account = result.getSignInAccount();
firebaseAuthWithGoogle(account);
} else {
// Google Sign In failed, update UI appropriately
// ...
firebaseAuthUpdateUI(null);
}
}
}
private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {
//Log.d(TAG, "firebaseAuthWithGoogle:" + acct.getId());
AuthCredential credential = GoogleAuthProvider.getCredential(acct.getIdToken(), null);
firebaseAuth.signInWithCredential(credential)
.addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
@Override
public void onComplete(@NonNull Task<AuthResult> task) {
if (task.isSuccessful()) {
// Sign in success, update UI with the signed-in user's information
//Log.d(TAG, "signInWithCredential:success");
user = firebaseAuth.getCurrentUser();
firebaseAuthUpdateUI(user);
} else {
// If sign in fails, display a message to the user.
//Log.w(TAG, "signInWithCredential:failure", task.getException());
Toast.makeText(SignInActivity.this, "Authentication failed.",
Toast.LENGTH_SHORT).show();
user = null;
//firebaseAuthUpdateUI(null);
}
// ...
}
});
}
...