【发布时间】:2021-07-21 10:12:50
【问题描述】:
我已经在我的 Android 应用中使用 Google 实现了 Firebase 身份验证。当我尝试使用它登录时,我收到了来自FirebaseUser 类的电子邮件null:
private fun firebaseAuthWithGoogle(idToken: String) {
val credential = GoogleAuthProvider.getCredential(idToken, null)
auth.signInWithCredential(credential)
.addOnCompleteListener(this) { task ->
if (task.isSuccessful) {
// Sign in success, update UI with the signed-in user's information
Log.d(TAG, "signInWithCredential:success")
val user = auth.currentUser
if(user.email != null) {
sendUserDetailToServer()
updateUI(user)
}
} else {
// If sign in fails, display a message to the user.
Log.w(TAG, "signInWithCredential:failure", task.exception)
updateUI(null)
}
}
}
我可以获得其他详细信息,例如姓名、uid 等。
【问题讨论】:
标签: android firebase kotlin firebase-authentication google-authentication