【问题标题】:error in linking phone authentication with email/password authentication将电话身份验证与电子邮件/密码身份验证链接时出错
【发布时间】:2018-09-10 02:14:19
【问题描述】:

我正在尝试将电子邮件身份验证与电话身份验证相关联,但我收到错误“java.lang.IllegalArgumentException:无法在没有验证证明、会话信息或临时证明的情况下创建 PhoneAuthCredential”找到我的代码来链接下面的两个身份验证提供程序。请指出正确的方向

// [START sign_in_with_phone]



private void linkWithCredential() {
    final PhoneAuthCredential credential = PhoneAuthProvider.getCredential(mVerificationId,mVerificationField.getText().toString());
    firebaseauth.getCurrentUser().linkWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (!task.isSuccessful()) {
                        Log.d(TAG, "linkWithCredential:success");
                        FirebaseUser user = task.getResult().getUser();
                        updateUI(user);
                    } else {
                        Log.w(TAG, "linkWithCredential:failure", task.getException());
                        Toast.makeText(Phone_Auth.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                        updateUI(null);
                    }
                }
            });
}
// [END sign_in_with_phone]

【问题讨论】:

  • 你能检查mVerificationIdmVerificationField.getText().toString()不为空吗?
  • 我得到了它的工作,但感谢您的意见
  • @DarkShadow 面临同样的问题。你是怎么解决的?
  • @sanidhya09 我发布了答案

标签: android firebase firebase-realtime-database firebase-authentication


【解决方案1】:

我解决了这个问题,但忘记发布答案这里是解决方案代码=

private void linkWithCredential(AuthCredential credential) {
           firebaseauth.getCurrentUser().linkWithCredential(credential)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    if (task.isSuccessful()) {
                        Log.d(TAG, "linkWithCredential:success");
                        FirebaseUser user = task.getResult().getUser();
                        updateUI(user);
                    } else {
                        Log.w(TAG, "linkWithCredential:failure", task.getException());
                        Toast.makeText(Phone_Auth.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                        updateUI(null);
                    }
                }
            });
}

【讨论】:

    猜你喜欢
    • 2018-09-09
    • 2019-05-20
    • 2016-11-20
    • 2019-07-13
    • 2020-05-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-05
    相关资源
    最近更新 更多