Firebaseui-ios: FirebaseAuthUI not creating new user from Facebook authentication - Swift

Created on 12 Jul 2016  路  26Comments  路  Source: firebase/FirebaseUI-iOS

After setting up FirebaseAuthUI for Facebook - adding the redirect URIs to my Facebook app login details, facebook app ID to the Info.plist - I'm able to get my simple test app to go through all the steps to authenticate Facebook, but upon completion no new user is created in the authentication database. The app will show up under permissions in my Facebook account, but no new user is created in Firebase.

Google authentication and email/password authentication work as expected and correctly create a new user.

This is the function I use for my simple sign-in button:

@IBAction func signIn() {

    let authUI = FIRAuthUI.authUI()!
    let googleAuthUI = FIRGoogleAuthUI.init(clientID:FIRApp.defaultApp()!.options.clientID)
    let facebookAuthUI = FIRFacebookAuthUI.init(appID: NSBundle.mainBundle().infoDictionary?["FacebookAppID"] as! String)  
    authUI.signInProviders = [googleAuthUI!, facebookAuthUI!]       

    let authViewController = FIRAuthUI.authUI()!.authViewController()        
    self.presentViewController(authViewController, animated: true, completion: nil)

}

(cross posted on: http://stackoverflow.com/questions/38317938/firebaseauthui-not-adding-new-facebook-user)

bug

Most helpful comment

Oh, I found the issue!

In my advanced settings within the facebook app, I had turned on "Is App Secret embedded in the client?"

Turning that off made it all work!
screen shot 2016-07-13 at 5 19 50 pm

All 26 comments

Are you getting any errors in the process? Can you check FIRAuth.auth()?.currentUser and see if there's a signed in user?

So I added FIRAuth.auth()?.addAuthStateDidChangeListener and I got it to fire with Google and email login, but not Facebook...

Just a quick check, have you enabled Facebook on Firebase console?

Yup it's enabled.
screen shot 2016-07-12 at 4 04 54 pm

Thanks! Can you please do the following to help debug the issue?

  • Make a temporary variable of the handleOpenURL result and place a breakpoint there.
func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    let handled = FIRAuthUI.authUI()!.handleOpenURL(url, sourceApplication: sourceApplication!)
    return handled
}
  • Start and finish a Facebook sign-in flow and you should hit the breakpoint.

If handled is false, most likely there's something wrong with the Facebook setup. Check your plist file against the "Configure Xcode Project" section of this doc, make sure there's a CFBundleURLSchemes value for Facebook in particular.

Put in the breakpoint and handled is true.

Hmm, are you getting any callback in func authUI(authUI: FIRAuthUI!, didSignInWithUser user: FIRUser?, error: NSError?)? Is the auth view controller dismissed after you sign in with Facebook?

Yes, the view controller is dismissed after signing in with Facebook and the app is shown as authorized in my facebook profile settings (for "Logged in using Facebook"). However, I'm not getting any callbacks for any of the sign-ins using the didSignInWithUser method. I do get a call with the FIRAuth.auth().addAuthStateDidChangeListener for Google and email/password (but not facebook).

Did you set the delegate of FIRAuthUI to the object that implements didSignInUser?

Oops, thanks. Ok with delegate assigned, I'm getting a callback for all three providers, but still no Facebook account creation.

Do you happen to use Facebook and Google accounts with the same email address? In this case, the two providers are linked to the same Firebase account.

Yes, however even without my Google account saved (I've tried deleting the account to have zero accounts at all in the database), the Facebook authentication still doesn't create a new user.

Also forgot to mention with didSignInUser, the user is nil when trying facebook login, but is assigned for Google/email.

Aha! Got the full error details - still not sure what the issue is as I've provided my app secret to Firebase?
FIRAuthErrorUserInfoDeserializedResponse -
"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\":\"ByZKant9ike\"}}"
-

Oh, I found the issue!

In my advanced settings within the facebook app, I had turned on "Is App Secret embedded in the client?"

Turning that off made it all work!
screen shot 2016-07-13 at 5 19 50 pm

@heydana Sory i cannot find is app secret embedded in the client?
where i can find?

@ryanzulham facebook app portal -> Settings -> Advanced (top most section right side slider)
screen shot 2017-02-08 at 10 46 33 pm

image

@kalehv this option is not there anymore. Any update please?

@ObamaBinLaden1 I still see it, not sure what's different

@heydana I disabled "Is App Secret embedded in the client". Still getting the same error.

Still not creating new user ?

you need check and change id + app secret this:
screen shot 2018-01-10 at 11 09 31 am

Hi, i also not getting that setting as mentioned above, also i have added appid and appsecret in firebase?

screen shot 2018-05-18 at 6 14 31 pm

The solution for me was rechecking the app secret. Previously, I had copied and pasted the secured text (the dots) into Firebase, but what I was actually pasting into Firebase was the dot symbols and not actually the app secret. In order to correct this, I had to hit "Show" next to the app secret in the Facebook app portal and then copy the app secret in its unhidden form.

In my case, it was a mismatch of the secret I had pasted into Firebase and the actual secret. I am bumping this with that context. If you are encountering this, triple-check your app id and secrets.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

willbattel picture willbattel  路  6Comments

crrobinson14 picture crrobinson14  路  9Comments

Ruberik picture Ruberik  路  8Comments

platoputhur picture platoputhur  路  4Comments

Vortec4800 picture Vortec4800  路  5Comments