2
votes

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) 
3
Would like to know more about the internal error you are encountering, could you print the error description to obtain more detailed information? The fact that you got an internal error just means that the Firebase client didn't understand the error that it's backend returned but the underlying error should be part of the NSError description. -- NSLog(@"%@", error.description); - Sparq

3 Answers

9
votes

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.

0
votes

On the Facebook Developer site, navigate to:

Settings > Advanced > Security > Require App Secret

Set to YES.

Fixed it for me.

0
votes

The following worked for me:

Go to android/app/src/main/res/values/strings.xml. Make sure you have the following line in your <resources>:

<string name="facebook_app_id">FACEBOOK*APP*ID</string>

where FACEBOOK*APP*ID is the your app ID from developers.facebook.com/apps