I use Firebase on Android and Firebase Auth functions.
I try FirebaseAuth.signInWithEmailAndPassword
and in case it fails I want to know why the signIn process failed?
The signInWithEmailAndPassword
method has addOnFailureListener
API.
And I can catch the Exception
(maybe FirebaseAuthException
) in onFailure
callback method.
auth.signInWithEmailAndPassword(loginRequest.id, loginRequest.password)
.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
if (e instanceof FirebaseAuthException) {
((FirebaseAuthException) e).getErrorCode());
}
}
});
I want to know why the SignIn process failed. in onFailure
.
I think it could be done as follows:
e
instance type check(e instanceOfFirebaseAuthInvalidUserException
orFirebaseAuthInvalidCredentialsException
or ,,,)e.getErrorCode()
I do not want to type checks (it's dirty).
I prefer the way in choice 2. above. But I could not find the definition of e.getErrorCode()
return values collection.
e.g ERROR_INVALID_EMAIL
, ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL
, etc.
(Where are they defined?)
How do I find out why Firebase auth failed?