I am using Facebook login with firebase in my ios app, but I can't save the user's data to the database because authWithOAuthProvider seems to be returning a differend uid string from the one I can see in the dashboard. Is this a known issue? Here is my code:
@IBAction func tappedFacebookLogin(sender: AnyObject) {
User.sharedModel.facebookUser = true
let loginManager = FBSDKLoginManager()
let permissions = ["public_profile", "email"]
loginManager.logInWithReadPermissions(permissions, fromViewController: self, handler: { fbResult, fbError in
if fbError != nil {
// error in login
print("fbError: \(fbError.code)")
}
else if fbResult.isCancelled {
// cancelled login
print("cancelled facebook login")
}
else {
// fb logged in
self.startProgressHud()
let accessToken = FBSDKAccessToken.currentAccessToken().tokenString
FirebaseManager.sharedRootRef.authWithOAuthProvider("facebook", token: accessToken, withCompletionBlock: { error, authData in
if error != nil {
self.handleFirebaseError(error)
}
else {
// firebase logged in
print(authData.uid)
self.getUserDataAndLogin(authData.uid)
}
})
}
})
}
发现虽然authWithOAuthProvider
打印的uid与auth仪表板中的uid不同, authWithOAuthProvider
每次都打印相同的uid,因此保存和检索用户数据实际上是authWithOAuthProvider
的,但这只是在auth仪表板中针对该用户出现的一个不同的uid。奇怪的原因。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.