Microsoft Authentication Library (MSAL) never returns from AcquireTokenAsync () on Android

I have an Xamarin.Forms iOS / Android application and you must authenticate the user against Microsoft Azure B2C AD.

I added Microsoft.Identity.Client NuGet and used this for authentication.

It works fine on iOS, but on Android, the same code never returns from AcquireTokenAsync ().

The login user interface is displayed as it should, and the accepted username and password and user interface presented by the MSAL library are rejected as it should, but the call await AcquireTokenAsync()never returns.

The code is in the PCL in the main application project.

I tried Android devices 4, 5, and 6.

I know that MSAL is still in alpha. I just would like to receive confirmation if this is because of this or I could do something wrong.

+4
source share
1 answer

Therefore, apparently, I need this piece of code in my MainActivity.cs, and I overlooked that in their example:

    protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
    {
        base.OnActivityResult(requestCode, resultCode, data);
        AuthenticationAgentContinuationHelper.SetAuthenticationAgentContinuationEventArgs(requestCode, resultCode, data);
    }
+10
source

All Articles