Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New Firebase Facebook login

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

like image 311
orim553 Avatar asked May 20 '16 21:05

orim553


1 Answers

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)

like image 131
tommybananas Avatar answered Sep 28 '22 09:09

tommybananas