An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
Hi @nandu kathmandi ,
Thanks for reaching out.
It looks like the authentication_canceled exceptions you’re seeing are most likely caused by how the Android activity lifecycle interacts with MSAL in .NET MAUI, rather than actual user cancellations. Even with .WithUseEmbeddedWebView(true), MSAL still launches a temporary AuthenticationAgentActivity, and if that activity is destroyed or not correctly tied to a stable parent, MSAL interprets it as the user canceling.
The users aren't noticing these failures, which is worth investigating carefully. MSAL does not automatically retry silently after an authentication_canceled - a canceled interactive flow leaves nothing new in the token cache, so any immediate silent call would just fail again with user_interaction_required.
The more likely explanation is that AcquireTokenInteractive is being called proactively somewhere in your app - on app resume, during page navigation, or as part of a background token check - rather than only in direct response to a user-initiated sign-in. In that case, the cancellation happens before the user even sees a login screen, so they never notice it, and the next attempt succeeds because the timing or lifecycle state is different by then.
I'd audit where AcquireTokenInteractive is being triggered across your app to confirm it's only called from explicit user actions.
Just to set expectations, MSAL will report authentication_canceled for any incomplete interactive flow, including:
- A fast back-press
- The activity being destroyed during a redirect
- Timing mismatches in the lifecycle
I suggest the following recommendations (you can treat these as a reference while verifying what applies best to your app):
- Use the current Android activity as the parent for MSAL calls:
.WithParentActivityOrWindow(Platform.CurrentActivity)
This is generally safer than passing App.RootViewController and avoids lifecycle mismatches.
- Remove
AuthenticationContinuationHelperif you’re using embedded webview, as it’s typically not required in modern MAUI apps and can sometimes introduce unnecessary handling, as confirmed in this MSAL GitHub issue.
While this is a non- Microsoft link, it is a official repository maintained by Microsoft.
- Make sure only one interactive authentication call runs at a time and avoid triggering it during page transitions or navigation events.
- Optional but helpful: set your
MainActivitylaunch mode toSingleTaskto reduce the chance of activity recreation during auth.
Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.