question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ClientAuthError: multiple_matching_tokens error when cache kept more than 2 users

See original GitHub issue

Core Library

MSAL Node (@azure/msal-node)

Core Library Version

1.5.0

Wrapper Library

Not Applicable

Wrapper Library Version

None

Description

When using a “singleton instance of confidentialClientApplication” we have found the “case that in cache there is two accounts, third account try to make first time a OBO and we get multiple_matching_tokens error.”

Originally posted by @CrazyBaran in https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/4158#issuecomment-944152234

With my team, we have found exactly the same issue… Maybe important to say that the cache has exactly 12 items when it happens.

@sameerag We are wondering if the potential solution is still alive, for it seems recently to be more or less without activity: https://github.com/AzureAD/microsoft-authentication-library-for-js/pull/4081

And by the way, the only quick workaround we’ve found so far is to always clear the cache XD Have you by chance found another one @CrazyBaran ?

MSAL Configuration

const config: Configuration = {
  auth: {
    clientId: 'our clientId',
    authority: 'https://login.microsoftonline.com/our tenantId',
    clientSecret: 'our clientSecret',
  },
};
this.cca = new ConfidentialClientApplication(config);

Relevant Code Snippets

const cachedAccount: AccountInfo = await this.cca
      .getTokenCache()
      .getAccountByLocalId((jwtDecode(token) as UserPayload).oid);
    if (cachedAccount?.localAccountId) {
      return await this.cca.acquireTokenSilent({
        account: cachedAccount,
        scopes: ['https://vault.azure.net/.default'],
        authority: 'https://login.microsoftonline.com/our tenantId',
      });
    }
	return this.cca.acquireTokenOnBehalfOf({
      oboAssertion: token.split(' ').pop(),
      scopes,
      authority: 'https://login.microsoftonline.com/our tenantId',
    });

Identity Provider

Azure AD / MSA

Source

External (Customer)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:26 (10 by maintainers)

github_iconTop GitHub Comments

3reactions
sameeragcommented, Apr 13, 2022

#4691 is a work in progress, ETA 4/22

2reactions
dillonbaileycommented, May 3, 2022

Thanks @sameerag - any new updates on targeted release?

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - multiple_matching_tokens_detected with ADAL
Solution for this is to catch error message, and in case error is multiple_matching_tokens_detected , then run AuthenticationContext.TokenCache.
Read more >
Acquire and cache tokens with Microsoft Authentication ...
MSAL maintains a token cache (or two caches for confidential client applications) and caches a token after it's been acquired. In many cases, ......
Read more >
Tip #1122: Multiple tokens in cache
For Package Deployer, for example, token cache is the file Default_PackageDeployer.tokens.dat and located in the C:\Users\<username>\AppData\ ...
Read more >
ClientAuthError | microsoft-authentication-libraries-for-js
Defined in msal-common/src/error/ClientAuthError.ts:389. Throws error if user sets CancellationToken.cancel = true during polling of token endpoint during ...
Read more >
Origin Cache Control - Cloudflare Docs
Set Cache-Control headers to tell Cloudflare how to handle content from the origin. When a user sends an HTTP request, the user's request ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found