New Firebase Facebook login

旧城冷巷雨未停 提交于 2020-01-01 05:14:32

问题


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.})


回答1:


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)




回答2:


// Auth with Firebase

FIRAuth.auth()?.signInWithCredential(credential) { (user, error) in

Also returns the same error code "FIRAuthErrorDomain" when I'm using GoogleSignIn. There are no description of the "FIRAuthErrorDomain" in the doc.



来源:https://stackoverflow.com/questions/37356395/new-firebase-facebook-login

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!