如何在 firebase 中访问用户的 facebook public 信息?
How to access the user's facebook public information in firebase?
我已经为我的应用请求并获得了 public_profile
和 email
的批准。
单击 login with Facebook
按钮后,我请求这两个权限:
let fbLoginManager = FBSDKLoginManager()
fbLoginManager.logIn(withReadPermissions: ["public_profile", "email"], from: self) { (result, error) in
成功登录流程后,我进入了用户已验证的部分。 (也许我做得太晚了,但不确定我还应该在哪里尝试访问个人资料信息?)
override func viewDidLoad() {
super.viewDidLoad()
FIRAuth.auth()!.addStateDidChangeListener() { auth, user in
if let user = user {
FIRDatastore.shared.setUser(user: User(authData: user))
self.performSegue(withIdentifier: self.loginToList, sender: nil)
}
}
}
在本例中,user
对象的类型为 FIRUser class。这应该包含 public 配置文件信息。但是,我只看到 authData.providerData[0]
下的一部分信息
providerID, userID, displayName, photoURL and email.
根据 here 的解释,我从 public_profile 中看不到性别或其他任何内容。
请问我错过了什么?
根据 documentation 这些是您可以访问的唯一用户属性:
类似于 User object 属性:
我猜 Facebook 身份验证仅用于电子邮件和密码验证。
我已经为我的应用请求并获得了 public_profile
和 email
的批准。
单击 login with Facebook
按钮后,我请求这两个权限:
let fbLoginManager = FBSDKLoginManager()
fbLoginManager.logIn(withReadPermissions: ["public_profile", "email"], from: self) { (result, error) in
成功登录流程后,我进入了用户已验证的部分。 (也许我做得太晚了,但不确定我还应该在哪里尝试访问个人资料信息?)
override func viewDidLoad() {
super.viewDidLoad()
FIRAuth.auth()!.addStateDidChangeListener() { auth, user in
if let user = user {
FIRDatastore.shared.setUser(user: User(authData: user))
self.performSegue(withIdentifier: self.loginToList, sender: nil)
}
}
}
在本例中,user
对象的类型为 FIRUser class。这应该包含 public 配置文件信息。但是,我只看到 authData.providerData[0]
providerID, userID, displayName, photoURL and email.
根据 here 的解释,我从 public_profile 中看不到性别或其他任何内容。
请问我错过了什么?
根据 documentation 这些是您可以访问的唯一用户属性:
类似于 User object 属性:
我猜 Facebook 身份验证仅用于电子邮件和密码验证。