I'm trying to implement Facebook NativeUI authentication in Xamarin.Forms PCL project for iOS, and have following problem.
I created authenticator in PCL library like this
authenticator = new OAuth2Authenticator(
clientId: ClientId,
scope: "",
authorizeUrl: FB_AUTH_URI //can't post link in here in forum
redirectUrl: FB_REDIRECT_URI //can't post link in here in forum
getUsernameAsync: null,
isUsingNativeUI: true
)
{
AllowCancel = true,
ShowErrors = false
};
authenticator.Completed += OnFacebookAuthCompleted;
authenticator.Error += OnFacebookAuthError;
AuthenticationState.Authenticator = authenticator;
var presenter = new Xamarin.Auth.Presenters.OAuthLoginPresenter();
presenter.Login(authenticator);
It works fine, FB page ask for email and password and user can login without any problem with his credentials.
The problem is when user want to login next time with another Facebook account. After first successful login, next time, FB login screen looks different. This time there is a question "You previously logged in to TestApp with Facebook. Would you like to continue?" and there are "Continue" and "Cancel" buttons.
It is perfect if user want to use same account, but if want to login with another and click "Cancel" application receive Error message ("OAuth Error = Permissions+error") and browser redirect to new blank page and only way to login to another account is to delete app and install it again, if not FB keep asking to login to previously used.
I guess, it is some my mistake, but can't find any solution myself. When using "Facebook not nativeUI" or "Google nativeUI" everything works fine, but in this case have no idea what to do.
How can I force app to forget previous account?
And another question, is there a way to close native browser page after unsuccessfully login? When user login successfully the page close itself but in case of error stay on blank page like in this example.