MsalUiRequiredException during silent token acquisition in Xamarin.Forms
0 reputation · 07 Jul 2020, 03:49 UTC
Authentication Flow Failure
In a Xamarin.Forms application utilizing MSAL.NET for Azure AD authentication, the application is designed to prioritize silent token acquisition to maintain a seamless user experience. The goal is to implement a least-privilege security model where tokens are refreshed automatically until they expire or are revoked.
Credential Expiration Constraints
While SecureStorage handles the persistence of the token cache, it does not provide native logic to detect when a refresh token has expired or been invalidated by the identity provider. When AcquireTokenSilent fails, the library throws an MsalUiRequiredException, signaling that interactive intervention is necessary.
There is uncertainty regarding the optimal trigger for transitioning from silent to interactive authentication without creating a disruptive user experience, especially when dealing with revoked sessions versus simple expiration.
- How should the application distinguish between a transient network failure and a permanent credential expiration within the
MsalUiRequiredExceptioncatch block? - What is the recommended pattern for clearing the local token cache before initiating the interactive login flow to ensure a clean state?