Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/180.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
如何在Android中重新验证使用Google帐户登录的Firebase用户?_Android_Firebase_Firebase Authentication_Google Signin - Fatal编程技术网

如何在Android中重新验证使用Google帐户登录的Firebase用户?

如何在Android中重新验证使用Google帐户登录的Firebase用户?,android,firebase,firebase-authentication,google-signin,Android,Firebase,Firebase Authentication,Google Signin,我正在尝试重新验证使用Google帐户登录的用户,以便将该用户链接到另一个凭据(电子邮件和密码)。这是我用来重新验证的代码: public Task<Void> reAuthenticateWithGoogle(Context context){ FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if(user == null) return null; GoogleSignInA

我正在尝试重新验证使用Google帐户登录的用户,以便将该用户链接到另一个凭据(电子邮件和密码)。这是我用来重新验证的代码:

public Task<Void> reAuthenticateWithGoogle(Context context){
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    if(user == null) return null;
    GoogleSignInAccount signInAccount = GoogleSignIn.getLastSignedInAccount(context);
    if(signInAccount == null) return null;
    AuthCredential credentialGoogle = GoogleAuthProvider.getCredential(signInAccount.getIdToken(), null);
    return user.reauthenticate(credentialGoogle);
}
使用Google重新验证公共任务(上下文){
FirebaseUser=FirebaseAuth.getInstance().getCurrentUser();
if(user==null)返回null;
GoogleSignInAccount signInAccount=GoogleSignIn.GetLastSignedAccount(上下文);
if(signInAccount==null)返回null;
AuthCredential CredentialGogle=GoogleAuthProvider.getCredential(signInAccount.getIdToken(),null);
返回用户。重新验证(Credentialogle);
}
但是,如果用户在执行此代码之前已登录五分钟或更长时间,则此操作不起作用。引发的错误是下一个错误:

E/CREATE_PASSWORD_ACT:创建密码时出错:提供的身份验证凭据格式错误或已过期。[在16024XXXXX签发的ID令牌已过期,无法登录。]

那么,对于只使用Google帐户登录的用户,哪种方法才是正确的重新验证方法

谢谢大家:)