diff --git a/lib/msal-node/src/client/ClientCredentialClient.ts b/lib/msal-node/src/client/ClientCredentialClient.ts index be0507fb4c..fa36f3e2f8 100644 --- a/lib/msal-node/src/client/ClientCredentialClient.ts +++ b/lib/msal-node/src/client/ClientCredentialClient.ts @@ -25,6 +25,7 @@ import { ServerAuthorizationTokenResponse, StringUtils, TimeUtils, + TokenCacheContext, UrlString, } from "@azure/msal-common"; @@ -71,6 +72,16 @@ export class ClientCredentialClient extends BaseClient { private async getCachedAuthenticationResult( request: CommonClientCredentialRequest ): Promise { + // read the user-supplied cache into memory, if applicable + if (this.config.serializableCache && this.config.persistencePlugin) { + const cacheContext = new TokenCacheContext( + this.config.serializableCache, + true, + ); + + await this.config.persistencePlugin.beforeCacheAccess(cacheContext); + } + const cachedAccessToken = this.readAccessTokenFromCache(); if (!cachedAccessToken) {