Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何捕获Firebase身份验证特定的异常_Java_Android_Exception_Firebase_Firebase Authentication - Fatal编程技术网

Java 如何捕获Firebase身份验证特定的异常

Java 如何捕获Firebase身份验证特定的异常,java,android,exception,firebase,firebase-authentication,Java,Android,Exception,Firebase,Firebase Authentication,使用Firebase,如何捕获特定异常并优雅地告诉用户该异常?例如: FirebaseAuthInvalidCredentialsException:电子邮件地址错误 格式化 我使用下面的代码使用电子邮件和密码注册用户,但我在java方面没有那么先进 mAuth.createUserWithEmailAndPassword(email, pwd) .addOnCompleteListener(this, new OnCompleteListener<AuthResult>()

使用Firebase,如何捕获特定异常并优雅地告诉用户该异常?例如:

FirebaseAuthInvalidCredentialsException:电子邮件地址错误 格式化

我使用下面的代码使用电子邮件和密码注册用户,但我在java方面没有那么先进

mAuth.createUserWithEmailAndPassword(email, pwd)
    .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {

    @Override
    public void onComplete(@NonNull Task<AuthResult> task) {
        if (!task.isSuccessful()) {
            //H.toast(c, task.getException().getMessage());
            Log.e("Signup Error", "onCancelled", task.getException());
        } else {
            FirebaseUser user = mAuth.getCurrentUser();
            String uid = user.getUid();
        }
    }    
});
mAuth.createUserWithEmailAndPassword(电子邮件,密码)
.addOnCompleteListener(这是新的OnCompleteListener(){
@凌驾
未完成的公共void(@NonNull任务){
如果(!task.issusccessful()){
//toast(c,task.getException().getMessage());
Log.e(“注册错误”,“取消”,task.getException());
}否则{
FirebaseUser=mAuth.getCurrentUser();
字符串uid=user.getUid();
}
}    
});
您应该使用
((FirebaseAuthException)task.getException()).getErrorCode()
获取错误类型,如果这是格式错误电子邮件的错误代码,则会正常失败

不幸的是,我找不到Firebase使用的错误代码列表。
触发异常一次,注意错误代码和相应的代码。

如果您正在从用户向云发送上游消息,请执行firebase回调函数
onMessageAgent
onSenderError
,以检查上游消息的状态。在错误情况下,
onSendError
返回带有错误代码的sendeexception


例如,如果客户端试图在达到20条消息的限制后发送更多消息,它将返回SendException#ERROR(错误)过多消息。

除了@pdegand59 answer之外,我在Firebase库中发现了一些错误代码,并在Android上进行了测试(返回的错误代码)。希望这有帮助,问候

 ("ERROR_INVALID_CUSTOM_TOKEN", "The custom token format is incorrect. Please check the documentation."));
 ("ERROR_CUSTOM_TOKEN_MISMATCH", "The custom token corresponds to a different audience."));
 ("ERROR_INVALID_CREDENTIAL", "The supplied auth credential is malformed or has expired."));
 ("ERROR_INVALID_EMAIL", "The email address is badly formatted."));
 ("ERROR_WRONG_PASSWORD", "The password is invalid or the user does not have a password."));
 ("ERROR_USER_MISMATCH", "The supplied credentials do not correspond to the previously signed in user."));
 ("ERROR_REQUIRES_RECENT_LOGIN", "This operation is sensitive and requires recent authentication. Log in again before retrying this request."));
 ("ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL", "An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address."));
 ("ERROR_EMAIL_ALREADY_IN_USE", "The email address is already in use by another account."));
 ("ERROR_CREDENTIAL_ALREADY_IN_USE", "This credential is already associated with a different user account."));
 ("ERROR_USER_DISABLED", "The user account has been disabled by an administrator."));
 ("ERROR_USER_TOKEN_EXPIRED", "The user\'s credential is no longer valid. The user must sign in again."));
 ("ERROR_USER_NOT_FOUND", "There is no user record corresponding to this identifier. The user may have been deleted."));
 ("ERROR_INVALID_USER_TOKEN", "The user\'s credential is no longer valid. The user must sign in again."));
 ("ERROR_OPERATION_NOT_ALLOWED", "This operation is not allowed. You must enable this service in the console."));
 ("ERROR_WEAK_PASSWORD", "The given password is invalid."));
 ("ERROR_MISSING_EMAIL", "An email address must be provided.";

您可以在try块内抛出由
task.getException
返回的异常,并捕获您正在使用的方法可能引发的每种类型的异常

下面是一个来自CompleteListener的示例,用于
createUserWithEmailAndPassword
方法

if(!task.isSuccessful()) {
    try {
        throw task.getException();
    } catch(FirebaseAuthWeakPasswordException e) {
        mTxtPassword.setError(getString(R.string.error_weak_password));
        mTxtPassword.requestFocus();
    } catch(FirebaseAuthInvalidCredentialsException e) {
        mTxtEmail.setError(getString(R.string.error_invalid_email));
        mTxtEmail.requestFocus();
    } catch(FirebaseAuthUserCollisionException e) {
        mTxtEmail.setError(getString(R.string.error_user_exists));
        mTxtEmail.requestFocus();
    } catch(Exception e) {
        Log.e(TAG, e.getMessage());
    }
}

您可以使用steve guidetti或pdegand59方法。我使用了steve guidetti的方法(缺少两个例外)

对于所有可能的例外情况,请参见以下参考

这里有很好的记录

搜索“createUserWithEmailAndPassword”并找到

错误代码

身份验证/电子邮件已在使用中

验证/无效电子邮件

不允许进行身份验证/操作

验证/弱密码

对于所有五种例外情况:检查此处

在这里您可以找到5种不同类型的AuthException。4个已知直接子类和1个间接子类


您可以使用steve guidetti或pdegand59方法。

我尝试了其他解决方案,但不喜欢它们

那么这个呢:

if (!task.isSuccessful()) {

    Exception exc = task.getException();

    if (exc.getMessage().contains("The email address is badly formatted.")) {
        etUser.setError(getString(R.string.error_wrong_email));
        etUser.requestFocus();
    }
    else
    if (exc.getMessage().contains("There is no user record corresponding to this identifier. The user may have been deleted.")) {
        etUser.setError(getString(R.string.error_user_not_exist));
        etUser.requestFocus();
    }
    else
    if (exc.getMessage().contains("The password is invalid or the user does not have a password")) {
        etPass.setError(getString(R.string.error_wrong_password));
        etPass.requestFocus();
    }


    Log.w(TAG, "signInWithEmail:failed", task.getException());


    Toast.makeText(AuthActivity.this, R.string.auth_failed,
            Toast.LENGTH_SHORT).show();
}

如果您只是想向用户显示一条消息,这是可行的。简约典雅:

if (!task.isSuccessful()) {
    Log.w(TAG, "signInWithEmail:failed", task.getException());
    Toast.makeText(LoginActivity.this, "User Authentication Failed: " + task.getException().getMessage(), Toast.LENGTH_SHORT).show();
}
.getMessage()方法似乎已经将异常转换为一种可用的格式,我们所要做的就是将其显示给用户

(这是我的第一个评论,请提出建设性的批评)


错误代码:

要捕获firebase异常很容易,您应该在添加
后添加
.addOnFailureListener
。addOnCompleteListener
如下:

 private void login_user(String email, String password) {

    mAuth.signInWithEmailAndPassword(email,password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
           if(task.isSuccessful()){
               Intent intent = new Intent(getApplicationContext(),MainActivity.class);
               startActivity(intent);
               finish();
           }if(!task.isSuccessful()){


                // To know The Excepton 
                //Toast.makeText(LoginActivity.this, ""+task.getException(), Toast.LENGTH_LONG).show();

           }
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            if( e instanceof FirebaseAuthInvalidUserException){
                Toast.makeText(LoginActivity.this, "This User Not Found , Create A New Account", Toast.LENGTH_SHORT).show();
            }
            if( e instanceof FirebaseAuthInvalidCredentialsException){
                Toast.makeText(LoginActivity.this, "The Password Is Invalid, Please Try Valid Password", Toast.LENGTH_SHORT).show();
            }
            if(e instanceof FirebaseNetworkException){
                Toast.makeText(LoginActivity.this, "Please Check Your Connection", Toast.LENGTH_SHORT).show();
            }
        }
    });
private void登录用户(字符串电子邮件、字符串密码){
mAuth.signInWithEmailAndPassword(电子邮件,密码)。addOnCompleteListener(新的OnCompleteListener(){
@凌驾
未完成的公共void(@NonNull任务){
if(task.issusccessful()){
Intent Intent=新的Intent(getApplicationContext(),MainActivity.class);
星触觉(意向);
完成();
}如果(!task.issusccessful()){
//认识例外者
//Toast.makeText(LoginActivity.this,“+task.getException(),Toast.LENGTH_LONG.show();
}
}
}).addOnFailureListener(新的OnFailureListener(){
@凌驾
public void onFailure(@NonNull异常e){
if(FirebaseAuthInvalidUserException的实例){
Toast.makeText(LoginActivity.this,“未找到此用户,请创建新帐户”,Toast.LENGTH_SHORT.show();
}
if(例如FirebaseAuthInvalidCredentialsException实例){
Toast.makeText(LoginActivity.this,“密码无效,请尝试有效密码”,Toast.LENGTH_SHORT).show();
}
if(FirebaseNetworkException的实例){
Toast.makeText(LoginActivity.this,“请检查您的连接”,Toast.LENGTH_SHORT.show();
}
}
});

登录异常

FirebaseAuthEmailException
FirebaseAuthException
-与Firebase身份验证相关的一般异常。有关详细信息,请查看错误代码和消息

ERROR\u USER\u DISABLE
D如果用户已被禁用(例如,在Firebase控制台中)

ERROR\u USER\u NOT\u FOUND
如果用户已被删除(例如,在Firebase控制台或此应用程序的其他实例中)

ERROR\u USER\u TOKEN\u EXPIRED
如果用户的令牌在后端被吊销。如果用户的凭据在另一个设备中发生更改(例如,在密码更改事件中),则会自动发生此情况

错误\u无效的\u用户\u令牌
如果用户的令牌格式不正确。正常情况下不应发生这种情况

mAuth.signInWithEmailAndPassword(login, pass)
  .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
          if(task.isSuccessful())
            {

            }else if (task.getException() instanceof FirebaseAuthInvalidUserException) {

            }else if(((FirebaseAuthException) task.getException()).getErrorCode().equals("ERROR_USER_DISABLED"))
            {

           }else if(((FirebaseAuthException) task.getException()).getErrorCode().equals("ERROR_USER_NOT_FOUND "))
          {

          }else if(((FirebaseAuthException) task.getException()).getErrorCode().equals("ERROR_USER_TOKEN_EXPIRED "))
         {

         }else if(((FirebaseAuthException) task.getException()).getErrorCode().equals("ERROR_INVALID_USER_TOKEN "))
         {
         }
 }
});
表示由于试图通过Firebase Auth发送电子邮件(例如密码重置电子邮件)而导致的异常

FirebaseAuthInvalidCredentialsException
-当传递给某个方法的一个或多个凭据无法识别和/或验证该操作的用户主体时引发。请检查错误代码和消息以找出具体原因

FirebaseAuthweakPasswordException
if (!task.isSuccessful()) {
    Log.w(TAG, "signInWithEmail:failed", task.getException());
    Toast.makeText(LoginActivity.this, "User Authentication Failed: " + task.getException().getMessage(), Toast.LENGTH_SHORT).show();
}
    try {
            throw task.getException();
        } catch(FirebaseAuthException e) {
           switch (e.getErrorCode()){
                        case "ERROR_WEAK_PASSWORD":
                      Toast.makeText(this, "The given password is invalid.", Toast.LENGTH_SHORT).show();
                             break;
                      //and other
                    }
        }
 private void login_user(String email, String password) {

    mAuth.signInWithEmailAndPassword(email,password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
           if(task.isSuccessful()){
               Intent intent = new Intent(getApplicationContext(),MainActivity.class);
               startActivity(intent);
               finish();
           }if(!task.isSuccessful()){


                // To know The Excepton 
                //Toast.makeText(LoginActivity.this, ""+task.getException(), Toast.LENGTH_LONG).show();

           }
        }
    }).addOnFailureListener(new OnFailureListener() {
        @Override
        public void onFailure(@NonNull Exception e) {
            if( e instanceof FirebaseAuthInvalidUserException){
                Toast.makeText(LoginActivity.this, "This User Not Found , Create A New Account", Toast.LENGTH_SHORT).show();
            }
            if( e instanceof FirebaseAuthInvalidCredentialsException){
                Toast.makeText(LoginActivity.this, "The Password Is Invalid, Please Try Valid Password", Toast.LENGTH_SHORT).show();
            }
            if(e instanceof FirebaseNetworkException){
                Toast.makeText(LoginActivity.this, "Please Check Your Connection", Toast.LENGTH_SHORT).show();
            }
        }
    });
mAuth.signInWithEmailAndPassword(login, pass)
  .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
          if(task.isSuccessful())
            {

            }else if (task.getException() instanceof FirebaseAuthInvalidUserException) {

            }else if(((FirebaseAuthException) task.getException()).getErrorCode().equals("ERROR_USER_DISABLED"))
            {

           }else if(((FirebaseAuthException) task.getException()).getErrorCode().equals("ERROR_USER_NOT_FOUND "))
          {

          }else if(((FirebaseAuthException) task.getException()).getErrorCode().equals("ERROR_USER_TOKEN_EXPIRED "))
         {

         }else if(((FirebaseAuthException) task.getException()).getErrorCode().equals("ERROR_INVALID_USER_TOKEN "))
         {
         }
 }
});
FirebaseAuthEmailException
private void loginUser(String email, String password) {

        mAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(new OnCompleteListener<AuthResult>() {

            @Override
            public void onComplete(@NonNull Task<AuthResult> task) {

                if (task.isSuccessful()) {

                    startActivity(new Intent(MainActivity.this, Main2Activity.class));

                } else {

                    String errorCode = ((FirebaseAuthException) task.getException()).getErrorCode();

                    switch (errorCode) {

                        case "ERROR_INVALID_CUSTOM_TOKEN":
                            Toast.makeText(MainActivity.this, "The custom token format is incorrect. Please check the documentation.", Toast.LENGTH_LONG).show();
                            break;

                        case "ERROR_CUSTOM_TOKEN_MISMATCH":
                            Toast.makeText(MainActivity.this, "The custom token corresponds to a different audience.", Toast.LENGTH_LONG).show();
                            break;

                        case "ERROR_INVALID_CREDENTIAL":
                            Toast.makeText(MainActivity.this, "The supplied auth credential is malformed or has expired.", Toast.LENGTH_LONG).show();
                            break;

                        case "ERROR_INVALID_EMAIL":
                            Toast.makeText(MainActivity.this, "The email address is badly formatted.", Toast.LENGTH_LONG).show();
                            etEmail.setError("The email address is badly formatted.");
                            etEmail.requestFocus();
                            break;

                        case "ERROR_WRONG_PASSWORD":
                            Toast.makeText(MainActivity.this, "The password is invalid or the user does not have a password.", Toast.LENGTH_LONG).show();
                            etPassword.setError("password is incorrect ");
                            etPassword.requestFocus();
                            etPassword.setText("");
                            break;

                        case "ERROR_USER_MISMATCH":
                            Toast.makeText(MainActivity.this, "The supplied credentials do not correspond to the previously signed in user.", Toast.LENGTH_LONG).show();
                            break;

                        case "ERROR_REQUIRES_RECENT_LOGIN":
                            Toast.makeText(MainActivity.this, "This operation is sensitive and requires recent authentication. Log in again before retrying this request.", Toast.LENGTH_LONG).show();
                            break;

                        case "ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL":
                            Toast.makeText(MainActivity.this, "An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.", Toast.LENGTH_LONG).show();
                            break;

                        case "ERROR_EMAIL_ALREADY_IN_USE":
                            Toast.makeText(MainActivity.this, "The email address is already in use by another account.   ", Toast.LENGTH_LONG).show();
                            etEmail.setError("The email address is already in use by another account.");
                            etEmail.requestFocus();
                            break;

                        case "ERROR_CREDENTIAL_ALREADY_IN_USE":
                            Toast.makeText(MainActivity.this, "This credential is already associated with a different user account.", Toast.LENGTH_LONG).show();
                            break;

                        case "ERROR_USER_DISABLED":
                            Toast.makeText(MainActivity.this, "The user account has been disabled by an administrator.", Toast.LENGTH_LONG).show();
                            break;

                        case "ERROR_USER_TOKEN_EXPIRED":
                            Toast.makeText(MainActivity.this, "The user\\'s credential is no longer valid. The user must sign in again.", Toast.LENGTH_LONG).show();
                            break;

                        case "ERROR_USER_NOT_FOUND":
                            Toast.makeText(MainActivity.this, "There is no user record corresponding to this identifier. The user may have been deleted.", Toast.LENGTH_LONG).show();
                            break;

                        case "ERROR_INVALID_USER_TOKEN":
                            Toast.makeText(MainActivity.this, "The user\\'s credential is no longer valid. The user must sign in again.", Toast.LENGTH_LONG).show();
                            break;

                        case "ERROR_OPERATION_NOT_ALLOWED":
                            Toast.makeText(MainActivity.this, "This operation is not allowed. You must enable this service in the console.", Toast.LENGTH_LONG).show();
                            break;

                        case "ERROR_WEAK_PASSWORD":
                            Toast.makeText(MainActivity.this, "The given password is invalid.", Toast.LENGTH_LONG).show();
                            etPassword.setError("The password is invalid it must 6 characters at least");
                            etPassword.requestFocus();
                            break;

                    }
                }
            }
        });
    }
com.firebase.ui.auth.IdpResponse
@Deprecated 
public int getErrorCode()
Get the error code for a failed sign in

Deprecated use getError() instead
protected void onActivityResult(int requestCode, int resultCode, Intent data) {

                super.onActivityResult(requestCode, resultCode, data);

                if (requestCode == RC_SIGN_IN) {
                    IdpResponse response = IdpResponse.fromResultIntent(data);

                    // Successfully signed in
                    if (resultCode == RESULT_OK) {
                        //dbHandler = DBMS.getInstance(this);

                        FirebaseAuth auth = FirebaseAuth.getInstance();
                        FirebaseUser user = auth.getCurrentUser();
                        FirebaseUserMetadata metadata = auth.getCurrentUser().getMetadata();

                        // initialize profile first
                        if (metadata.getCreationTimestamp() == metadata.getLastSignInTimestamp()) {



                            //start main activity after profile setup
                            startActivity(new Intent(this, MainActivity.class));
                            return;
                        } else {
                            // This is an existing user
                            // show them a welcome back screen.

                            startActivity(new Intent(this, MainActivity.class));
                            return;
                        }
                    } else {
                        // Sign in failed
                        // check response for error code
                        if (response == null) {
                            // User pressed back button
                            showSnackbar(R.string.sign_in_cancelled);
                            return;
                        }

                        if (response.getError().getErrorCode() == ErrorCodes.NO_NETWORK) {
                            showSnackbar(R.string.no_internet_connection);
                            return;
                        }

                        if (response.getError().getErrorCode() == ErrorCodes.UNKNOWN_ERROR) {
                            showSnackbar(R.string.unknown_error);
                            return;
                        }
                    }
                    showSnackbar(R.string.unknown_sign_in_response);
                }
            }
if (task.isSuccessful()) {
    //Toast.makeText(getContext(),"Registration successful", Toast.LENGTH_SHORT).show();
    try {
        Toast.makeText(getContext(),"Registration successful", Toast.LENGTH_SHORT).show();
        throw task.getException();
    }
    // if user enters wrong email.
    catch (FirebaseAuthWeakPasswordException weakPassword) {
        Log.d("Registration Error", "onComplete: weak_password");

        // TODO: take your actions!
    }
    // if user enters wrong password.
    catch (FirebaseAuthInvalidCredentialsException malformedEmail) {
        Log.d("Registration Error", "onComplete: malformed_email");

        // TODO: Take your action
    }
    catch (FirebaseAuthUserCollisionException existEmail) {
        Log.d("Registration Error", "onComplete: exist_email");

        // TODO: Take your action
    }
    catch (Exception e) {
        Log.d("Registration Error", "onComplete: " + e.getMessage());
    }
} else {
    //Toast.makeText(getContext(), "ERROR, Please try again.", Toast.LENGTH_SHORT).show();
    Toast.makeText(getContext(), task.getException().getMessage(), Toast.LENGTH_SHORT).show();
}
mAuth.getCurrentUser().linkWithCredential(authCredential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        Log.d(TAG, "linkWithCredential:success");
                    } else {
                        Log.w(TAG, "linkWithCredential:failure", task.getException());
                        Toast.makeText(getApplicationContext(), "Authentication failed. " + task.getException().toString, Toast.LENGTH_SHORT).show();

                    }

                    // ...
                }
            });
 fun signInWithEmail(email: String, passKey: String) {
    FirebaseAuth.getInstance().signInWithEmailAndPassword(email, passKey).addOnSuccessListener {
        it.user?.let {
            authResultOperation.postValue(AuthResultOperation.OnSuccessSignIn)
        }
    }.addOnFailureListener {
        val errorCode = (it.exception as FirebaseAuthException).errorCode
        val errorMessage = authErrors[errorCode] ?: R.string.error_login_default_error
        Toast.makeText(context, context.getString(errorMessage),Toast.LENGTH_LONG).show()
    }
}
val authErrors = mapOf("ERROR_INVALID_CUSTOM_TOKEN" to R.string.error_login_custom_token,
        "ERROR_CUSTOM_TOKEN_MISMATCH" to R.string.error_login_custom_token_mismatch,
        "ERROR_INVALID_CREDENTIAL" to R.string.error_login_credential_malformed_or_expired,
        "ERROR_INVALID_EMAIL" to R.string.error_login_invalid_email,
        "ERROR_WRONG_PASSWORD" to R.string.error_login_wrong_password,
        "ERROR_USER_MISMATCH" to R.string.error_login_user_mismatch,
        "ERROR_REQUIRES_RECENT_LOGIN" to R.string.error_login_requires_recent_login,
        "ERROR_ACCOUNT_EXISTS_WITH_DIFFERENT_CREDENTIAL" to R.string.error_login_accounts_exits_with_different_credential,
        "ERROR_EMAIL_ALREADY_IN_USE" to  R.string.error_login_email_already_in_use,
        "ERROR_CREDENTIAL_ALREADY_IN_USE" to R.string.error_login_credential_already_in_use,
        "ERROR_USER_DISABLED" to R.string.error_login_user_disabled,
        "ERROR_USER_TOKEN_EXPIRED" to R.string.error_login_user_token_expired,
        "ERROR_USER_NOT_FOUND" to R.string.error_login_user_not_found,
        "ERROR_INVALID_USER_TOKEN" to R.string.error_login_invalid_user_token,
        "ERROR_OPERATION_NOT_ALLOWED" to R.string.error_login_operation_not_allowed,
        "ERROR_WEAK_PASSWORD" to R.string.error_login_password_is_weak)
  <resources>
    <string name="error_login_custom_token">The custom token format is incorrect. Please check the documentation.</string>
    <string name="error_login_custom_token_mismatch">The custom token corresponds to a different audience.</string>
    <string name="error_login_credential_malformed_or_expired">The supplied auth credential is malformed or has expired.</string>
    <string name="error_login_invalid_email">The email address is badly formatted.</string>
    <string name="error_login_wrong_password">The password is invalid or the user does not have a password.</string>
    <string name="error_login_user_mismatch">The supplied credentials do not correspond to the previously signed in user.</string>
    <string name="error_login_requires_recent_login">This operation is sensitive and requires recent authentication. Log in again before retrying this request.</string>
    <string name="error_login_accounts_exits_with_different_credential">An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address.</string>
    <string name="error_login_email_already_in_use">The email address is already in use by another account.</string>
    <string name="error_login_credential_already_in_use">This credential is already associated with a different user account.</string>
    <string name="error_login_user_disabled">The user account has been disabled by an administrator.</string>
    <string name="error_login_user_not_found">There is no user record corresponding to this identifier. The user may have been deleted.</string>
    <string name="error_login_operation_not_allowed">This operation is not allowed. You must enable this service in the console.</string>
    <string name="error_login_password_is_weak">The given password is invalid.</string>
    <string name="error_login_user_token_expired">The user\'s credential is no longer valid. The user must sign in again</string>
    <string name="error_login_invalid_user_token">The user\'s credential is no longer valid. The user must sign in again.</string>
</resources>
    firebaseAuth.signInWithEmailAndPassword(email, password)
        .addOnCompleteListener {
            if (it.isSuccessful) {
                [...]
            } else {
                [FirebaseTooManyRequestsException and others that can be returned here]
            }
        }