Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MSAL does not throw UiRequiredException when it should (Android Broker scenarios) #2140

Closed
shristikatiyar opened this issue Oct 27, 2020 · 4 comments

Comments

@shristikatiyar
Copy link

Which Version of MSAL are you using ?
4.20

Platform
Xamrin.Android

What authentication flow has the issue?
Mobile

Other? - please describe;

Is this a new or existing app?
The app is in production and we have migrated from ADAL to MSAL

Repro

            authResult = await pc.AcquireTokenSilent(scopes, account).ExecuteAsync();

            DataInsightsProvider.Instance.TrackEvent(DataInsightsEvents.FetchTokenSilentlySuccess);
        }
        catch (MsalUiRequiredException e)
        {
            // This exception is expected if there is no token in the cache.
            this.logger.Log($"{_logTagAuth}: Encountered error during silent authentication." +
                                            $" Error code = {e.ErrorCode}. Exception: {e}");
        }

Expected behavior
If a silent token acquisitaion call fails due to reason such as (no account found or broken resfresh toke is invalid) insted of MSAL Service Exception we should get MSAL UI Required Exception so that we a interactive signin is performed.

Actual behavior
For some user in their session when a silent token acquistion is taking place MSAL Service Exception is thrown from broker
with error codes no_account_found or broker refresh token is invalid

Possible Solution
These error should throw a MSAL UI Required Exception

Additional context/ Logs / Screenshots
{"Error Message":"Non-Graph Authentication Error:","Exception Message":"Broker response returned error: Account does not exist in the broker, cannot proceed with silent request"}
"Message":"nt.Internal.Requests.SilentBrokerAuthStrategy.SendTokenRequestToBrokerAsync ()

From the logs from telemetry error is returned from this function (while broker is trying to silently acquire token)

@bgavrilMS
Copy link
Member

@shristikatiyar - what exactly are the error codes (verbatim)? You mentioned no_account_found and smth related to refresh token.

@bgavrilMS
Copy link
Member

P1 since user impact is that they can't login or app crashes.

@bgavrilMS bgavrilMS added this to Todo/Committed in MSAL.NET (legacy) via automation Oct 28, 2020
@bgavrilMS
Copy link
Member

We need to find out the exact error codes which need to be translated to MsalUiRequiredException from Android broker.

@bgavrilMS bgavrilMS moved this from Todo/Committed to vNext in MSAL.NET (legacy) Oct 28, 2020
@bgavrilMS bgavrilMS changed the title Getting MSAL Service Exception no_account_found and Broker refresh token is invalid MSAL does not throw UiRequiredException when it should (Android Broker scenarios) Oct 28, 2020
@shristikatiyar
Copy link
Author

We need to find out the exact error codes which need to be translated to MsalUiRequiredException from Android broker.

Hi Bogdan , these are the two error codes we are getting. attaching the screenshot

Broker refresh token is invalid
no_account_found

Screenshot (137)

@bgavrilMS bgavrilMS moved this from vNext to Todo/Committed in MSAL.NET (legacy) Nov 5, 2020
@bgavrilMS bgavrilMS added this to To do in 4.23.0 via automation Nov 5, 2020
@bgavrilMS bgavrilMS added this to the 4.23 milestone Nov 5, 2020
@jennyf19 jennyf19 self-assigned this Nov 18, 2020
@jennyf19 jennyf19 moved this from Todo/Committed to In Progress in MSAL.NET (legacy) Nov 18, 2020
@jennyf19 jennyf19 moved this from In Progress to Fixed in MSAL.NET (legacy) Nov 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

3 participants