I am using the following code:
try
{
authResult = await app.AcquireTokenInteractive(App.ApiScopes)
.WithUseEmbeddedWebView(false)
.WithParentActivityOrWindow(new WindowInteropHelper(this).Handle)
.ExecuteAsync();
}
catch (MsalClientException ex)
{
msg = $"Error Acquiring Token: {ex}";
}
I want to handle the case where the user is prompted to the login page, but then closes it or navigates away. For this I have observed two conflicting behaviours being documented.
On the one hand it is stated on the following wiki that MSAL will throw a MsalClientException with the error code authentication_canceled , if when calling AcquireTokenInteractive(), the user closes the process or hits the back button on their browser.
https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/exceptions#common-exceptions
On the other hand on azure documentation it is stated that MSAL.NET cannot detect if the user closes the login page or navigates away.
https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-net-web-browsers#system-browser-experience-on-net
I have confirmed that my code exhibits the later behaviour, so no exception is thrown. If that is the case and MSAL.NET cannot detect such browser behaviour, then is there a valid scenario, where the login page is closed and the program throws a MsalClientException?
I am using the following code:
I want to handle the case where the user is prompted to the login page, but then closes it or navigates away. For this I have observed two conflicting behaviours being documented.
On the one hand it is stated on the following wiki that MSAL will throw a
MsalClientExceptionwith the error codeauthentication_canceled, if when callingAcquireTokenInteractive(), the user closes the process or hits the back button on their browser.https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/exceptions#common-exceptions
On the other hand on azure documentation it is stated that MSAL.NET cannot detect if the user closes the login page or navigates away.
https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-net-web-browsers#system-browser-experience-on-net
I have confirmed that my code exhibits the later behaviour, so no exception is thrown. If that is the case and MSAL.NET cannot detect such browser behaviour, then is there a valid scenario, where the login page is closed and the program throws a
MsalClientException?