Token cache not used for Standard client #7314
Labels
b2c
Related to Azure B2C library-specific issues
bug-unconfirmed
A reported bug that needs to be investigated and confirmed
msal-browser
Related to msal-browser package
msal-react
Related to @azure/msal-react
public-client
Issues regarding PublicClientApplications
question
Customer is asking for a clarification, use case or information.
Core Library
MSAL.js (@azure/msal-browser)
Core Library Version
3.23.0
Wrapper Library
MSAL React (@azure/msal-react)
Wrapper Library Version
2.0.22
Public or Confidential Client?
Public
Description
I create MSAL lib instance with PublicClientApplication type. When I request a token with
acquireTokenSilent
the lib always makes a network request. My request looks like this:I tried requesting only the scope for the API and adding all default scopes. But it always skips the cache.
I looked into the implementation of
StandardController.ts
in the source files of the lib and it seems that it doesn't try to use the cache. It has some logic to reuse currently executing requests with the same params with this code:const cachedResponse = this.activeSilentTokenRequests.get(silentRequestKey);
But the tokenCache or browserCache is not used anywhere in this controller class it seems.
Error Message
No response
MSAL Logs
[Mon, 16 Sep 2024 21:38:26 GMT] : [] : @azure/[email protected] : Info - Emitting event: msal:acquireTokenStart
msalConfig.ts:64 [Mon, 16 Sep 2024 21:38:26 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
msalConfig.ts:64 [Mon, 16 Sep 2024 21:38:27 GMT] : [] : @azure/[email protected] : Info - CacheManager:getAccessToken - Returning access token
msalConfig.ts:64 [Mon, 16 Sep 2024 21:38:27 GMT] : [0191fcc5-cc31-7cc4-9b45-8b3b198d41a0] : @azure/[email protected] : Info - Token refresh is required due to cache outcome: 3
msalConfig.ts:64 [Mon, 16 Sep 2024 21:38:27 GMT] : [] : @azure/[email protected] : Info - Emitting event: msal:acquireTokenFromNetworkStart
msalConfig.ts:64 [Mon, 16 Sep 2024 21:38:27 GMT] : [] : @azure/[email protected] : Info - CacheManager:getIdToken - Returning ID token
msalConfig.ts:64 [Mon, 16 Sep 2024 21:38:27 GMT] : [] : @azure/[email protected] : Info - CacheManager:getRefreshToken - returning refresh token
Network Trace (Preferrably Fiddler)
MSAL Configuration
Relevant Code Snippets
Reproduction Steps
Expected Behavior
A cached token is used until if it is not expired and only after that a new request should be made.
Identity Provider
Azure B2C Custom Policy
Browsers Affected (Select all that apply)
Chrome, Safari
Regression
No response
Source
External (Customer)
The text was updated successfully, but these errors were encountered: