darwin-morocho / flutter-facebook-auth

A flutter plugin to add login with facebook in your flutter app
193 stars 127 forks source link

Unable to switch Facebook user #33

Closed mchurichi closed 3 years ago

mchurichi commented 3 years ago

Describe the bug Hey, thanks for this plugin. I'm facing an issue when trying to test the app with multiple Facebook users. The first time I run the app it asks for my Facebook credentials and then signs me in, but when I try to trigger the login again it just prompts to log in with the same user just by clicking Continue, or Cancel the login, I don't have an option to sign in as a different user. I even tried login me out but still the same.

Environment Flutter 1.22.2 on an iOS Emulator running iOS 14.2. flutter_facebook_auth: 1.0.1

To Reproduce

  _onSignInWithFacebook() async {
    try {
      AccessToken accessToken = await FacebookAuth.instance.isLogged;
      if (accessToken != null) {
        await FacebookAuth.instance.logOut();
      }
      accessToken = await FacebookAuth.instance.login();
      final userData = await FacebookAuth.instance.getUserData();
      print(userData);
    } catch (e, s) {
      if (e is FacebookAuthException) {
        print(e.message);
        switch (e.errorCode) {
          case FacebookAuthErrorCode.OPERATION_IN_PROGRESS:
            print("You have a previous login operation in progress");
            break;
          case FacebookAuthErrorCode.CANCELLED:
            print("login cancelled");
            break;
          case FacebookAuthErrorCode.FAILED:
            print("login failed");
            break;
        }
      }
    }
  }

Expected behavior Every time it opens the facebook login it should let me log in as a previous user OR as a different user.

darwin-morocho commented 3 years ago

@mchurichi this plugin use the official Facebook sdk when you call to login you always see a confirmation page to allow the login. Could you send me that page?. I think the Facebook sdk must allow switch the account in this page.

mchurichi commented 3 years ago

Thanks for the quick response, this is the page I see when I trigger the log in process: (sorry it's in spanish, but I think you know the language)

image

I only see the option to Continue or Cancel, no option to switch user, may I be doing something wrong? Didn't post my pubspec or Info.plist because I think they are not related with the issue, but I can do it if needed. Hitting continue gets me the right AccessToken, cancel raises a FacebookAuthErrorCode.CANCELLED FacebookAuthException.

darwin-morocho commented 3 years ago

@mchurichi after check the official Facebook sdk docs I found that the switch account is not available for Android and ios. https://developers.facebook.com/docs/facebook-login/reauthentication/

https://github.com/facebook/facebook-ios-sdk/issues/1147#issuecomment-728812072

mchurichi commented 3 years ago

oh man that's insane, you can't even properly log out, facebook always keeps you session somewhere... I know that's out of your plugin's scope, thanks for your help!