[Bug] GetAccountAsync returns null when account is in returned collection from GetAccountsAsync
See original GitHub issueWhich Version of MSAL are you using ? MSAL 4.17.1, MSAL 4.19.0
Platform xamarin android
What authentication flow has the issue?
- Desktop / Mobile
- Interactive
- Integrated Windows Auth
- Username Password
- Device code flow (browserless)
- Web App
- Authorization code
- OBO
- Web API
- OBO
Other? - please describe;
Is this a new or existing app? The app is in production, I haven’t upgraded MSAL, but started seeing this issue. I am not able to say exactly after which version I stared seeing this issue
Repro
var account = await _msalClient
.GetAccountAsync(identifier)
.ConfigureAwait(false);
if (account == null)
{
var accounts = await _msalClient.GetAccountsAsync();
account = accounts.FirstOrDefault(a => a.HomeAccountId.Identifier.Equals(identifier, StringComparison.OrdinalIgnoreCase));
}
return account;
Expected behavior The account for the given identifier should be returned from the GetAccountAsync(identifier) call
Actual behavior GetAccountAsync(identifier) returns null but the call to get all accounts and then select the first 1 with the given identifier does return an account. GetAccountsAsync() returns many duplicate accounts (45 accounts in my case but only has 5 distinct accounts)
This is using brokered authentication with Authenticator
Possible Solution
Additional context/ Logs / Screenshots Authenticator Incident ID: 3SNRN2DT
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top GitHub Comments
Verified that this works (with both content provider and account manager) on the latest main (4.30.1).
GetAccountAsync
finds the account correctly andGetAccountsAsync
returns only unique accounts. There’s been a few refactorings to that code since 4.19. Closing; @bemartin please reopen if it’s still an issue.@trwalke - can you take a look at this as you are investigating other issues in Android area?