Microsoft-authentication-library-for-dotnet: [Bug] AcquireTokenInteractive not return when use SystemWebView with Apple IdP (B2C)

Created on 16 Jun 2020  路  7Comments  路  Source: AzureAD/microsoft-authentication-library-for-dotnet

I try implementing Sing in with Apple in my app with AD B2C according to the following sample:
https://github.com/azure-ad-b2c/samples/tree/master/policies/sign-in-with-apple

With this provider, I attempt to sign in with the AcquireTokenInteractive method on SystemWebView.
It seems that the auth is complete, but the SystemWebView remains display white page, and the WebView is not closed and the control does not return to the app.

Which Version of MSAL are you using ?
MSAL 4.14.0

Platform
Xamarin iOS

What authentication flow has the issue?

  • Desktop / Mobile

    • [x] Interactive

    • [ ] Integrated Windows Auth

    • [ ] Username Password

    • [ ] Device code flow (browserless)

  • Web App

    • [ ] Authorization code

    • [ ] OBO

  • Web API

    • [ ] OBO

Is this a new or existing app?
This app is in production.
I'm implementing Sign in with Apple, and I have upgraded to a new version of MSAL.

Repro

  1. Do Sign in with Apple on SystemWebBrowser using the following code:
authResult = await _client.AcquireTokenInteractive(Scopes)
    .WithParentActivityOrWindow(UIParent)
    .WithAccount(GetAccountByPolicy(acounts, PolicySignUpSignIn))
    .WithPrompt(Prompt.SelectAccount)
    .WithUseEmbeddedWebView(false)
    .ExecuteAsync();

Expected behavior

When complete to sign in, the callback URL will be redirected, and the system browser will be closed and then the auth result will be returned.

Actual behavior
When complete to sign in, the callback URL was redirected.
But the system browser was not closed, remained a white page, and the auth result was not returned.

Possible Solution

If we use the EmbeddedWebView, it works expectedly.

authResult = await _client.AcquireTokenInteractive(Scopes)
    .WithParentActivityOrWindow(UIParent)
    .WithAccount(GetAccountByPolicy(acounts, PolicySignUpSignIn))
    .WithPrompt(Prompt.SelectAccount)
    .WithUseEmbeddedWebView(true)
    .ExecuteAsync();

However, this workaround causes the google sign in problem the following:
https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-net-aad-b2c-considerations#google-auth-and-embedded-webview

Additional context/ Logs / Screenshots

IMG_2918

answered duplicate question

Most helpful comment

Ah, never mind @jennyf19, I think I found an issue that you worked on and describes this problem: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/1491

@muak - see the investigation in issue #1491 , it seems there is a problem in iOS itself, which should have been fixed in 13.4

All 7 comments

@jennyf19 - do you remember similar issues on B2C with Apple accounts + system webview?

Ah, never mind @jennyf19, I think I found an issue that you worked on and describes this problem: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/1491

@muak - see the investigation in issue #1491 , it seems there is a problem in iOS itself, which should have been fixed in 13.4

@bgavrilMS
Thank you for your time and reply.

This issue was completely the same as #1491.
It solved when I updated iOS version 13.3 to 13.5.

Thanks.

Thanks for the quick response @muak

@bgavrilMS I'm facing the same issue but with Xamarin Android in the simulator. None of the actions on the B2C webview are reacting and redirecting back to the underlying code. It is not redirecting back to the app

@justinasfour04 we recommend using a device whenever possible, as there are differences in behavior between the simulator and device. @jkdouglas can you help the above, is this something you've seen w/the Apple IdP on simulator? thanks.

I was missing the manifest file edits that are needed as described here https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-net-xamarin-android-considerations#update-the-android-manifest

Was this page helpful?
0 / 5 - 0 ratings