AzureAD / microsoft-authentication-library-for-js

Microsoft Authentication Library (MSAL) for JS
http://aka.ms/aadv2
MIT License
3.64k stars 2.65k forks source link

acquireTokenSilent : ERROR InteractionRequiredAuthError: no_tokens_found: No refresh token found in the cache. Please sign-in #7252

Closed hansakaRightS closed 2 months ago

hansakaRightS commented 2 months ago

Core Library

MSAL.js (@azure/msal-browser)

Core Library Version

3.0.4

Wrapper Library

MSAL Angular (@azure/msal-angular)

Wrapper Library Version

3.1.0

Public or Confidential Client?

Public

Description

We are calling acquireTokenSilent to get a new token without affecting the user experience , but this throw an error whenever we call the it. (we tried calling this 20 seconds after the login success)

since this error we have to force call the acquireTokenRedirect to get the token, which affect user experience because webpage is refresh when this happens

Error : 
`ERROR 
InteractionRequiredAuthError: no_tokens_found: No refresh token found in the cache. Please sign-in.`

Error Message

ERROR InteractionRequiredAuthError: no_tokens_found: No refresh token found in the cache. Please sign-in.

MSAL Logs

No response

Network Trace (Preferrably Fiddler)

MSAL Configuration

{
auth: {
        clientId: clientId,
        authority: "B2C_1A_SIGNUP_SIGNIN",
        redirectUri: '/',
        navigateToLoginRequestUrl: false
    },
    cache: {
        cacheLocation: "LocalStoarage",
        storeAuthStateInCookie: false
    }
}

Relevant Code Snippets

this.msalService.acquireTokenSilent({
         scopes:[`https://${environment.activeDirectory.domain}/${environment.activeDirectory.tenantId}/access_as_user`],
         forceRefresh: false,
         account: this.msalService.instance.getActiveAccount()
});

Reproduction Steps

  1. successful login.
  2. call acquireTokenSilent.

Expected Behavior

we should be able to get a new token.

Identity Provider

Azure B2C Custom Policy

Browsers Affected (Select all that apply)

Chrome, Firefox, Edge, Safari, Other

Regression

No response

Source

External (Customer)

tnorling commented 2 months ago

Please upgrade to the latest version and if this is still an issue please provide trace level logs

hansakaRightS commented 2 months ago

@tnorling Thanks for the reply. let me update the to the latest version and get back to you.

How can I acquire the trace level log?

hansakaRightS commented 2 months ago

@tnorling small question, is it normal behavior to see page refresh on the acquireTokenSilent method is called?

tnorling commented 2 months ago

https://github.com/AzureAD/microsoft-authentication-library-for-js/blob/dev/lib/msal-browser/docs/logging.md

hansakaRightS commented 2 months ago

Thanks @tnorling Updating the package fixed the problem i was having, but i still experience the page refresh when we call the acquireTokenSilent. is that expected?

tnorling commented 2 months ago

Great, thanks for confirming the upgrade fixed the issue, I'm going to go ahead and close this as resolved.

acquireTokenSilent will not cause the page to refresh on its own, this is typically caused by logic implemented by the app to react to events or results of the call, such as falling back to acquireTokenRedirect in the case of a failure, or rerendering content or redirecting to another page upon a success. That's something you'll need to debug on your side.