gpt4 book ai didi

android - GoogleSignInAccount getIdToken() 为空

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:04:08 24 4
gpt4 key购买 nike

嘿,我正在使用 Firebase 身份验证并启用了 Google 登录 功能。Google 登录运行良好,我获得了所有信息。但是当我想将用户保存在 Firebase 用户列表中时,getIdToken() 为空:

private void firebaseAuthWithGoogle(GoogleSignInAccount acct) {       

//here the acct.getIdToken() is null

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()) {
Toast.makeText(SignIn.this, "Authentication failed.", Toast.LENGTH_SHORT).show();
}

// [START_EXCLUDE]
progressDialog.hide();
// [END_EXCLUDE]
}
});

}

最佳答案

也许您忘记了在您的 GoogleSignInOptions 对象上使用 requestIdToken()

尝试一下:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestIdToken(getString(R.string.default_web_client_id))
.requestEmail()
.build();

关于android - GoogleSignInAccount getIdToken() 为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43179362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com