新的Firebase Facebook登录 [英] New Firebase Facebook login
问题描述
这是Facebook登录的代码
let facebookLogin = FBSDKLoginManager()
facebookLogin.logInWithReadPermissions([email],fromViewController:self){(result,error) - >无效
如果错误!= nil {
print(error is \(error))
} else {
let accessToken = FBSDKAccessToken.currentAccessToken()。tokenString
让凭证= FIRFacebookAuthProvider.credentialWithAccessToken(accessToken)
AUTH?.signInWithCredential(凭证,完成:{(user,error) - >无效
$ if
print(error is \(error))
} else {
print(user)
NSUserDefaults.standardUserDefaults()。setValue (user?.uid,forKey:KEY_UID)
self.performSegueWithIdentifier(SEGUE_LOGGEDIN,sender:nil)
}
})
}
这是我得到的错误代码
可选(错误域= FIRAuthErrorDomain代码= 17999内部错误已占有UserInfo = {error_name = ERROR_INTERNAL_ERROR,NSUnderlyingError = 0x79f082b0 {Error Domain = FIRAuthInternalErrorDomain Code = 3(null)UserInfo = {FIRAuthErrorUserInfoDeserializedResponseKey = {type = immutable dict,count = 3 ,
entries =>
0:{contents =errors} = {type = immutable,count = 1,values =(
b
$ b0:{type =不可变dict,count = 3,
条目=>
0:{contents =原因} = {contents =invalid}
$ b <1> {contents =message} = {contents =来自Facebook的debug_token失败:{error :{message:OAuth访问令牌签名无效。,type:OAuthException,code:190,fbtrace_id:BrewfOSy / fH}}}
2:{contents =domain} = {contents =global}
}
)}
$ b1:{contents =code} = {value = +400,type = kCFNumberSInt64Type}
< {error:{message:无效的OAuth访问令牌签名,type:OAuthException, code:190,fbtrace_id:BrewfOSy / fH}}}
}
} },NSLocalizedDescription =发生了一个内部错误,打印并检查错误的详细信息以获得更多信息})
确保您在Firebase控制台中输入正确的FACEBOOK App ID和App Secret。 (不是您的XCode应用程序ID)
I'm trying to make a Facebook login with the new Firebase platform.
this is the code for the facebook login
let facebookLogin = FBSDKLoginManager()
facebookLogin.logInWithReadPermissions(["email"], fromViewController: self) { (result, error) -> Void in
if error != nil {
print("error is \(error)")
} else {
let accessToken = FBSDKAccessToken.currentAccessToken().tokenString
let credential = FIRFacebookAuthProvider.credentialWithAccessToken(accessToken)
AUTH?.signInWithCredential(credential, completion: { (user, error) -> Void in
if error != nil {
print("error is \(error)")
} else {
print(user)
NSUserDefaults.standardUserDefaults().setValue(user?.uid, forKey: KEY_UID)
self.performSegueWithIdentifier(SEGUE_LOGGEDIN, sender: nil)
}
})
}
and this is the error code i get
Optional(Error Domain=FIRAuthErrorDomain Code=17999 "An internal error has occurred, print and inspect the error details for more information." UserInfo={error_name=ERROR_INTERNAL_ERROR, NSUnderlyingError=0x79f082b0 {Error Domain=FIRAuthInternalErrorDomain Code=3 "(null)" UserInfo={FIRAuthErrorUserInfoDeserializedResponseKey={type = immutable dict, count = 3, entries =>
0 : {contents = "errors"} = {type = immutable, count = 1, values = (
0 : {type = immutable dict, count = 3, entries =>
0 : {contents = "reason"} = {contents = "invalid"}
1 : {contents = "message"} = {contents = "Unsuccessful debug_token response from Facebook: {"error":{"message":"Invalid OAuth access token signature.","type":"OAuthException","code":190,"fbtrace_id":"BrewfOSy/fH"}}"}
2 : {contents = "domain"} = {contents = "global"} }
)}
1 : {contents = "code"} = {value = +400, type = kCFNumberSInt64Type}
2 : {contents = "message"} = {contents = "Unsuccessful debug_token response from Facebook: {"error":{"message":"Invalid OAuth access token signature.","type":"OAuthException","code":190,"fbtrace_id":"BrewfOSy/fH"}}"}
}
}}, NSLocalizedDescription=An internal error has occurred, print and inspect the error details for more information.})
Make sure you enable Facebook authentication in your firebase console.
Make sure you enter the correct FACEBOOK App ID and App Secret in the firebase console. (Not your XCode App ID)
这篇关于新的Firebase Facebook登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!