我想问问是否有人可以指导我如何使用 Facebook 的帐户工具包为 firebase 添加电话登录的示例或解释。
我正在从 facebook account kit 获取 accessToken,然后尝试像这样授权
fileprivate func authorizeWithAccessToken(_ accessToken: AKFAccessToken?, phoneNumber: AKFPhoneNumber?, error: NSError?) {
guard let accessToken = accessToken else {
return
}
FIRAuth.auth()?.signIn(withCustomToken: accessToken.tokenString) { (user, error) in
if (error != nil) {
print(error?.localizedDescription)
} else {
print("User logged in")
}
}
}
但是我得到了错误:
"The custom token format is incorrect. Please check the documentation." UserInfo={NSLocalizedDescription=The custom token format is incorrect. Please check the documentation., error_name=ERROR_INVALID_CUSTOM_TOKEN})
这是我的代币:
EMAWeGCejpgSijO0ncgBYl7HxLTZBy0rWrwaHihA81ZB286EEPhdZCtDSWZAnajp8pmX10E1ZCJDV7Ghwz0NrxRMhZCgSPzZC9imjbamk8bvv2AZDZD
最佳答案
为什么您使用 customTokens 进行 Facebook 身份验证,而不是使用 Firebase 为 Facebook 提供的内置凭证方法?
使用 Facebook 库创建凭证对象而不是 token :
let credential = FIRFacebookAuthProvider.credential(withAccessToken: FBSDKAccessToken.current().tokenString)
并将此对象传递给 signIn(with: )
方法。
FIRAuth.auth()?.signIn(with: credential) { (user, error) in
if let err = error {
print(err?.localizedDescription)
return
}
// Do your stuff here....
}
可以找到使用 Firebase 和 Facebook 的完整文档 here
关于iOS:Firebase 和 facebook 帐户工具包登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42211014/