【发布时间】:2018-11-20 22:55:36
【问题描述】:
我正在使用 Google 身份验证对 Firebase 上的用户进行身份验证。代码运行没有错误,但是,我在 Firebase 控制台的“身份验证”选项卡下看不到任何经过身份验证的用户。根据分析,存在用户活动,但没有任何使用 Google 登录的用户的记录。
func sign(_signIn: GIDSignIn!, didSignInfor user: GIDGoogleUser!, withError error: Error!){
if let err = error {
print ("failed to log into Google", err)
return
}
guard let authentication = user.authentication else { return }
let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken,
accessToken: authentication.accessToken)
Auth.auth().signInAndRetrieveData(with: credential, completion: { (authResult, error) in
if let error = error {
print ("failed to create with google account")
return
}
// User is signed in
guard let uid = user?.userID else {
return
}
我遵循了 Firebase 上的文档并启用了“Google 登录”。提前致谢!
【问题讨论】:
-
uid是否已增值? -
@Kerberos 抱歉,最后一部分让它有点混乱。该行不应影响将用户添加到 Firebase 控制台上的“身份验证”选项卡。
-
不,但它可以帮助我们了解它是否有登录。可以尝试在返回前加一些断点检查一下。
标签: swift firebase firebase-authentication google-authentication