Facebook login through WebAuthenticator in MAUI Android

73 Views Asked by At

I am integrating Facebook authenticating in .net Maui app through WebAuthenticator for IOS it's work fine but when i am trying the same code for Android it take me to facebook authentication page where i can enter my Facebook email and password after that when i click on login then from Facebook page it open a blank screen with navigation bar where my app name written on this screen if i use android back button functionality then it take me back to Facebook page if i again click back button then it take me back to my app login screen.

    [IntentFilter(new[] { Intent.ActionView },
     Categories = new[] { Intent.CategoryDefault, Intent.CategoryBrowsable },
      DataScheme = CALLBACK_SCHEME)]
    public class WebAuthenticationCallbackActivity : Microsoft.Maui.Authentication.WebAuthenticatorCallbackActivity
    {
        const string CALLBACK_SCHEME = "com.myapp.r1";

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
        }

        public override void OnCreate(Bundle savedInstanceState, PersistableBundle persistentState)
        {
            base.OnCreate(savedInstanceState, persistentState);
        }


        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);
        }
    }```


**ManifestFile**

<queries>
        <intent>
            <action android:name="android.support.customtabs.action.CustomTabsService" />
        </intent>
    </queries>


var response = await Microsoft.Maui.Authentication.WebAuthenticator.AuthenticateAsync(new WebAuthenticatorOptions()
                {
                    Url = new Uri("https://www.facebook.com/v12.0/dialog/oauth?client_id={clientId}&redirect_uri=fbconnect://cct.com.myapp.r1&response_type=token&scope={scope}"),
                    CallbackUrl = new Uri("fbconnect://cct.com.myapp.r1"),
                    PrefersEphemeralWebBrowserSession = true
                });
                string accessToken = response?.AccessToken;


0

There are 0 best solutions below