Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase : Facebook authentification with Firebase token not working

I'm trying to get working Facebook authentification in my app.

I'm following instructions here : https://firebase.google.com/docs/auth/ios/facebook-login

When I clicked on the Facebook login button, everything is working fine : the user is logged. In the facebook login delegate method, it is ok :

    func loginButton(_ loginButton: FBSDKLoginButton!, didCompleteWith result: FBSDKLoginManagerLoginResult!, error: Error!)

In this method, I have to create a Firebase token to authenticate finally with Firebase (step 5). This is what I do :

let credential = FacebookAuthProvider.credential(withAccessToken: 
FBSDKAccessToken.current().tokenString)
            Auth.auth().signIn(with: credential) { (user, error) in
                if let error = error {
                    print(error.localizedDescription)
                    self.errorServer()
                } else {
                    FitUtils.setFitUser(user: user)
                }
            }

The problem : My credential variable is not nil, everything is working, but when i'm calling Auth.auth().signIn(...), the method throwns the error variable, and user is nil.

I don't have many information about the error :

An internal error has occurred, print and inspect the error details for more information.

And

error   NSError domain: "FIRAuthErrorDomain" - code: 17999  0x0000604000640630

I suspect an error about the Facebook API key or something like that in the Firebase console, but I already checked everything is fine.

Any idea ?

EDIT

I found an explicit description of the error :

UserInfo={FIRAuthErrorUserInfoDeserializedResponseKey={
    code = 400;
    errors =     (
                {
            domain = global;
            message = "Unsuccessful debug_token response from Facebook: {\"error\":{\"message\":\"(#100) You must provide an app access token or a user access token that is an owner or developer of the app\",\"type\":\"OAuthException\",\"code\":100,\"fbtrace_id\":\"GkGVPPBP7vo\"}}";
            reason = invalid;
        }
    );
    message = "Unsuccessful debug_token response from Facebook: {\"error\":{\"message\":\"(#100) You must provide an app access token or a user access token that is an owner or developer of the app\",\"type\":\"OAuthException\",\"code\":100,\"fbtrace_id\":\"GkGVPPBP7vo\"}}";
}}}}
(lldb) 
like image 584
AnthonyR Avatar asked May 13 '26 00:05

AnthonyR


2 Answers

Finally found an answer thanks to this post :

https://github.com/firebase/FirebaseUI-iOS/issues/83#issuecomment-232523935

I have to disable the option "Is App Secret embedded in the client?" in the Facebook console :

enter image description here

Hope this helps.

like image 129
AnthonyR Avatar answered May 15 '26 16:05

AnthonyR


On the Facebook Developer site, navigate to:

Settings > Advanced > Security > Require App Secret

Set to YES.

Fixed it for me.

like image 22
bkSwifty Avatar answered May 15 '26 14:05

bkSwifty