[Bug] multiple_matching_tokens_detected occors when response does not include scope and AcquireTokenSilent does not include default scopes #5094
Labels
needs attention
Delete label after triage
public-client
untriaged
Do not delete. Needed for Automation
Library version used
4.67.2
.NET version
dotnet 9
Scenario
PublicClient - desktop app
Is this a new or an existing app?
This is a new app or experiment
Issue description and reproduction steps
After a token refresh my cache gets corrupted with 2 tokens, this means I get the dreaded multiple_matching_tokens_detected forcing me to log out the user and prompting them to login again. In my scenario I'm using a custom server using the
WithOidcAuthority
option. This server is using OpendIddict for it's implementaiton. After doing a fair bit of debugging I've been able to determine the following.AcquireTokenInteractive
with scopesmy-scope profile openid
my-scope profile openid offline_access
my-scope profile openid offline_access
and stored in the cacheAcquireTokenSilent
with scopesmy-scope profile openid
offline_access
scopemy-scope profile openid offline_access
based on the request that was executed it usesmy-scope profile openid
my-scope profile openid
is cached, however since it doesn't match the previous token's scopes it stores bothRelevant code snippets
Expected behavior
I would expect to not have the cache corrupted with 2 tokens and just replace the previous one on refresh
Identity provider
Other
Regression
No response
Solution and workarounds
I was able to work around this be ensuring that when I call
AcquireTokenInteractive
andAcquireTokenSilent
I always include the scopesprofile openid offline_access
in addition to whatever I'm requesting.I suspect this could be fixed by changing
to this:
as
_requestParams
represents what's passed in fromAcquireToken*
butscopes
includes the default scopes injected into every requestThe text was updated successfully, but these errors were encountered: