Open ppapageo opened 3 years ago
@ppgpn : this is a valid scenario, but MSAL.NET is not notified. @bgavrilMS to keep me honest
Yes, if you use an embedded browser, then MSAL knows if the end-user closes it. If you use a system browser, this is just process to process communication, i.e. MSAL kick starts it via "open https://login.microsoft.com/stuff" and waits for the user to complete authentication. There is no way for MSAL to know if the user navigates away or closes the window.
We've added support for embedded browser on .NET Core as well, maybe you want to use that? https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/WebView2
Thank you for the responses,
I was assuming that B2C would send an error as a response, as it does with other behaviours happening on the system browser login, (e.g. the forgot password error code). I use the CancellationToken
so that, at some point, I will get a timeout.
Unfortunately I cannot use the embedded browser because I need social logins which afaik need to be performed on the system browser.
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
MsalClientException
with 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-exceptionsOn 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
?