1

I am using the plugin flutter_facebook_auth: ^3.3.2-no-nullsafety on my Flutter app. Users can log in using Facebook to get Firebase Authentication:

    LoginResult facebookLoginResult = await FacebookAuth.instance.login(
        permissions: ['user_friends'],
        loginBehavior: LoginBehavior.WEB_VIEW_ONLY);
    if (faceBookLoginResult.status == LoginStatus.success) {
        AccessToken _accessToken = facebookLoginResult.accessToken;
        final userData = await FacebookAuth.instance.getUserData();
        final FacebookAuthCredential facebookAuthCredential =
            FacebookAuthProvider.getCredential(accessToken: _accessToken.token);
        name = userData['name'];
        await FirebaseAuth.instance
            .signInWithCredential(facebookAuthCredential); 
     }
   }

The code works as expected. But after a Facebook user is logged on to a device, I cannot sign in as a different user. For example, if I restart and go to the login dialog, and then enter login name and password for a different user, I get the dialog box: "You previously logged in to (this app) with Facebook. Would you like to continue?" The only options are "Continue", which signs in the previous user, or "cancel", which cancels the sign in.

I have tried a number of other ways to remove the Facebook user from the device :

  1. Clearing the app cache on the device
  2. Clearing the browser cache on the device
  3. Deleting the Facebook user in the "Authentication" panel of the Firebase Console
  4. Deleting the instance of the Facebook user altogether (it was a Facebook test user)

None of this worked.

I would really appreciate some help as it is impossible to debug the login flow if I can't sign in as a new user to test.

  • You need to call a method to logout and clear the session created through Facebook login – Quick learner Apr 20 '21 at 14:36
  • Thanks for your help. Unfortunately calling `FacebookAuth.instance.logOut()` successfully logged out the current user but when attempting a re-signin the dialog still pops up: "You previously logged in to (this app) with Facebook. Would you like to continue?" – nicholas_randall Apr 21 '21 at 07:48
  • you need to find out how to clear Facebook session cache also – Quick learner Apr 21 '21 at 17:06

0 Answers0