question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] MSAL not working with MAUI in iOS

See original GitHub issue

Logs and network traces https://pastebin.com/B7ux36cs (anonymized) and then https://pastebin.com/1tJTqDWE

Which version of MSAL.NET are you using? Microsoft.Identity.Client 4.39.0

Platform .NET MAUI preview 11 running on iOS

What authentication flow has the issue?

  • Desktop / Mobile
    • Interactive
    • Integrated Windows Authentication
    • Username Password
    • Device code flow (browserless)
  • Web app
    • Authorization code
    • On-Behalf-Of
  • Daemon app
    • Service to Service calls

Is this a new or existing app? This is a new app, but the same code does work in Xamarin.Forms/.iOS.

Repro

Create a .NET MAUI app from the default template, add MSAL and try to log in with AAD B2C. I use the following code to bootstrap MSAL:

AuthClient = PublicClientApplicationBuilder.Create(AuthConstants.ClientId)
		.WithIosKeychainSecurityGroup(AuthConstants.IosKeychainSecurityGroups)
		.WithB2CAuthority($"{AuthConstants.Authority}{AuthConstants.SigninPolicy}")
		.WithRedirectUri($"msal{AuthConstants.ClientId}://auth")
		.Build();

and

var result = await AuthClient
				.AcquireTokenInteractive(AuthConstants.DefaultScopes)
				.WithPrompt(Prompt.SelectAccount)
				.WithUseEmbeddedWebView(true)
				.ExecuteAsync().ConfigureAwait(false);

Expected behavior To get a AuthenticationResult like on Windows/Android.

Actual behavior Browser is closed and the debug log logs the attached exception and no user is logged in.

Additional context / logs / screenshots / links to code

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:5
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
chrfincommented, Jan 21, 2022

@bgavrilMS I just updated to MAUI preview 12 and now it does not compile anymore, as it does not find `AuthenticationContinuationHelper`.

I guess this is because MAUI does not support the Xamarin.iOS TFMs anymore (see here) and uses another more common one, which does not have this class.

1reaction
chrfincommented, Feb 17, 2022

Thank you for the update. I will finish the Android version of the app first to get something out to testers and then look into iOS again and see if I’m able to contribute something 😊.

Read more comments on GitHub >

github_iconTop Results From Across the Web

MAUI msal login issue on iOS
I have a MAUI application with SSO login, and it's working perfectly on android. But in iOS getting the below error while login....
Read more >
MSAL Not Working With .Net MAUI For Mac Platform
I am trying to get Microsoft AAD Authentication using MSAL in .net Maui Mac Desktop Application. It works in Android and iOS but...
Read more >
MSAL Not Working With .Net MAUI For Mac Platform
I am trying to get Microsoft AAD Authentication using MSAL in .net Maui Mac Desktop Application. It works in Android and iOS but...
Read more >
MSAL Auth in MAUI Revisited: The .NET Show with Carl Franklin
Carl updates episode 24, "Calling Secured APIs with MSAL Auth in MAUI " to use .NET 7 and to also work on Windows...
Read more >
Authenticate the .NET MAUI App with Azure AD
This article explains how to authenticate a .NET MAUI application using Azure Active Directory on Windows and Android platforms.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found