7

I have a Xamarin.Forms iOS/Android app and have to authenticate the user against a Microsoft Azure B2C AD.

I have added the Microsoft.Identity.Client NuGet and using this for authentication.

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

The login UI is shown as it should and the username and password accepted and the UI presented by the MSAL library dismisses as it should but the call to await AcquireTokenAsync() never returns.

The code is in a PCL in the core project of the app.

I have tried on Android 4, 5 and 6 devices.

I know MSAL is still in alpha I just would like to have confirmation if this due to that or I might be doing something wrong.

Nicolai Henriksen
  • 1,324
  • 1
  • 13
  • 37
  • 1
    Maybe more promising to file an issue over at https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues and also try to use the library from source to see where it gets stuck, – Krumelur Jun 14 '16 at 11:39

1 Answers1

12

So 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);
    }
Nicolai Henriksen
  • 1,324
  • 1
  • 13
  • 37