Open AdzeB opened 2 months ago
cc @Robbie-Microsoft @bgavrilMS
@Robbie-Microsoft @bgavrilMS could you help here? We are hitting the same issue. (not sure if the root causes are the same or different) I wonder if it could be related to a recent code change or something on msal side?
In our setup, We have a nodejs app and we use InteractiveBrowserCredential from @azure/identity along with @azure/identity-cache-persistence. We don't implement any custom cache plugin in our code.
Here is my call stack (it might be irrelevant since it's bundled but it might help with the class/fn names.)
InteractionRequiredAuthError: no_tokens_found: No refresh token found in the cache. Please sign-in.
at createInteractionRequiredAuthError (getCredential-QYKZSYTT.js:6046:10)
at _RefreshTokenClient.acquireTokenWithCachedRefreshToken (getCredential-QYKZSYTT.js:7082:17)
at getCredential-QYKZSYTT.js:2019:16
at _RefreshTokenClient.acquireTokenByRefreshToken (getCredential-QYKZSYTT.js:7071:211)
at async withSilentAuthentication (getCredential-QYKZSYTT.js:17186:22)
at async (getCredential-QYKZSYTT.js:18751:11)
at async Object.withSpan (chunk-FUS4SMZ3.js:552:26)
at async getCredential (getCredential-QYKZSYTT.js:19923:32)
error Command failed with exit code 1.
InteractiveBrowserCredential is a public client scenario and @Robbie-Microsoft and I don't own this scenario.
Updating the issue.
CC @peterzenz
Why was this clsoe?
I'm sickened by the awful developer experience in dealing with Microsoft and Azure.
@AdzeB - how do you get the first set of tokens? Do you use AcquireTokenByAuthCode?
Hi @bgavrilMS I used getAuthCodeUrl
const authCodeUrlParameters: AuthorizationUrlRequest = {
scopes: OUTLOOK\_SCOPES,
redirectUri: redirectUri,
// prompt: "consent", // Force a new consent prompt
// extraQueryParameters: {
// response\_mode: "query", // Ensures compatibility with various OAuth flows
// },
responseMode: "query",
prompt: "consent", // Force a new consent prompt
extraQueryParameters: {
response\_mode: "query",
access: "offline", // Explicitly request offline access
},
};
// Generate the authorization URL
const authUrl = await getMsalClient(supabase, userId).getAuthCodeUrl(
authCodeUrlParameters,
);
console.log("alok", authUrl);
return authUrl;
export function getMsalClient(supabase: SupabaseClient, userId: string) {
return new ConfidentialClientApplication(msalConfig(supabase, userId));
}
Seeing the same issue when using msal-node. Acquiring first token with acquireTokenByCode is successful but when i try to use acquireTokenSilent with the same scope and account object that i recieved from acquireTokenByCode response im seeing this error:
Folks, I'm not able to reproduce this error. Via our msal-node Silent Flow sample, I plugged in my own clientId and used a clientCertificate (thumbprint + private key) instead of clientSecret on lines 236-240 in index.js. I used msal-node v2.13.1 like specified above.
It would be helpful to a have a minimal bug repro to work on.
Core Library
MSAL Node (@azure/msal-node)
Core Library Version 2.15.0
Wrapper Library Not Applicable
Wrapper Library Version N/A
Public or Confidential Client? Confidential
Description Acquiring first token with acquireTokenByCode is successful but when trying to use acquireTokenSilent with the same scope and account object that i recieved from acquireTokenByCode response im seeing this error.
Error Message
[InteractionRequiredAuthError: no_tokens_found: No refresh token found in the cache. Please sign-in.] { errorCode: 'no_tokens_found', errorMessage: 'No refresh token found in the cache. Please sign-in.', subError: '', name: 'InteractionRequiredAuthError', timestamp: '', traceId: '', correlationId: '31fccaf9-c819-4c7f-8514-1cb3462ce8fb', claims: '', errorNo: undefined }
MSAL Logs
[Mon, 28 Oct 2024 12:16:01 GMT] : [] : @azure/msal-node@2.15.0 : Verbose - initializeRequestScopes called [Mon, 28 Oct 2024 12:16:01 GMT] : [31fccaf9-c819-4c7f-8514-1cb3462ce8fb] : @azure/msal-node@2.15.0 : Verbose - buildOauthClientConfiguration called [Mon, 28 Oct 2024 12:16:01 GMT] : [31fccaf9-c819-4c7f-8514-1cb3462ce8fb] : @azure/msal-node@2.15.0 : Verbose - createAuthority called [Mon, 28 Oct 2024 12:16:01 GMT] : [] : @azure/msal-node@2.15.0 : Verbose - Attempting to get cloud discovery metadata from authority configuration [Mon, 28 Oct 2024 12:16:01 GMT] : [] : @azure/msal-node@2.15.0 : Verbose - Did not find cloud discovery metadata in the config... Attempting to get cloud discovery metadata from the hardcoded values.
[Mon, 28 Oct 2024 12:16:01 GMT] : [] : @azure/msal-node@2.15.0 : Verbose - Found cloud discovery metadata from hardcoded values. [Mon, 28 Oct 2024 12:16:01 GMT] : [] : @azure/msal-node@2.15.0 : Verbose - Attempting to get endpoint metadata from authority configuration [Mon, 28 Oct 2024 12:16:01 GMT] : [] : @azure/msal-node@2.15.0 : Verbose - Did not find endpoint metadata in the config... Attempting to get endpoint metadata from the hardcoded values. [Mon, 28 Oct 2024 12:16:01 GMT] : [] : @azure/msal-node@2.15.0 : Verbose - Replacing tenant domain name with id {tenantid} [Mon, 28 Oct 2024 12:16:01 GMT] : [31fccaf9-c819-4c7f-8514-1cb3462ce8fb] : @azure/msal-node@2.15.0 : Info - Building oauth client configuration with the following authority: https://login.microsoftonline.com/tenant-id/oauth2/v2.0/token. [Mon, 28 Oct 2024 12:16:01 GMT] : [31fccaf9-c819-4c7f-8514-1cb3462ce8fb] : @azure/msal-node@2.15.0 : Verbose - Silent flow client created [Mon, 28 Oct 2024 12:16:01 GMT] : [] : @azure/msal-common@14.15.0 : Info - CacheManager:getAccessToken - No token found [Mon, 28 Oct 2024 12:16:01 GMT] : [31fccaf9-c819-4c7f-8514-1cb3462ce8fb] : @azure/msal-common@14.15.0 : Info - Token refresh is required due to cache outcome: 2 [Mon, 28 Oct 2024 12:16:01 GMT] : [] : @azure/msal-common@14.15.0 : Info - CacheManager:getRefreshToken - No refresh token found.
MSAL Configuration
const msalConfig = { auth: { clientId: process.env.AZURE_AD_CLIENT_ID, authority: https://login.microsoftonline.com/${process.env.AZURE_AD_TENANT_ID}, clientSecret: process.env.AZURE_AD_SECRET, }, cache: { cacheLocation: "localStorage" }, system: { loggerOptions: { logLevel: msal.LogLevel.Verbose, loggerCallback: (level: any, message: any, containsPii: any) => { if (containsPii) { return; } switch (level) { case msal.LogLevel.Error: console.error(message); return; case msal.LogLevel.Info: console.info(message); return; case msal.LogLevel.Verbose: console.debug(message); return; case msal.LogLevel.Warning: console.warn(message); return; } }, piiLoggingEnabled: false, }, }, };
Reproduction Steps This is happening inside next.js 13 API Routes
Successful login using acquireTokenByCode function with following scope
const scope = ['openid', 'api://client-id/app-name']
Call AcquireTokenSilent
Expected Behavior we should be able to get a new token.
Identity Provider Entra ID
Hi, any updates/fixes on the issue above?
Sorry, the bot keeps closing it this.
Folks, we have not been able to reproduce this issue. Can someone please provide a minimal repo? I can see in the original post a custom cache, it's not enough to repro. Could someone pls create a small sample that reproduces the issue?
@bgavrilMS How you like the sample to work, would you like it with supabase etc set up…you just need to enter the keys?
We can provision our own Entra ID app, redirect URI, secret etc.
Core Library
MSAL Node (@azure/msal-node)
Core Library Version
2.13.1
Wrapper Library
Not Applicable
Wrapper Library Version
N/A
Public or Confidential Client?
Public
Description
We are calling
acquireTokenSilent
to get a new token without needing the user to give permissions again, but the function throws the erroracquireTokenSilent : ERROR InteractionRequiredAuthError: no_tokens_found: No refresh token found in the cache. Please sign-in
Error Message
MSAL Logs
Network Trace (Preferrably Fiddler)
MSAL Configuration
Relevant Code Snippets
Reproduction Steps
Expected Behavior
we should be able to get a new token.
Identity Provider
Entra ID (formerly Azure AD) / MSA
Browsers Affected (Select all that apply)
None (Server)
Regression
N/A
Source
External (Customer)