How to solve CacheManager:getIdToken - No token found error?

Devesh 40 Reputation points
2023-06-02T06:24:37.8033333+00:00

I am using MSAL in React App. After the sign-in, I am getting the details using this code-

const [userDetails, setUserDetails] = useState(null); 
useEffect(() => {
    instance
      .handleRedirectPromise()
      .then(() => {
        const currentUser = instance.getAllAccounts()[0];
        setUserDetails(currentUser);
      })
      .catch((error) => console.log(error));
  }, []);

In the first load, I am getting these details in the const userDetails-

{
    "homeAccountId": "XX-X553252fedd35",
    "environment": "login.XX.net",
    "tenantId": "XX-63c7-XX-91c6-553252fedd35",
    "username": "******@XX.XX.com",
    "localAccountId": "XX-7e21-4730-XX-XX",
    "name": "XX XX",
    "idToken": "xcasdcasdf3adsfa4sdafsd43fadsf43asdfxx"
    "idTokenClaims": {
     XXXX: XXXX
    }
}

First load- Screenshot

But when I reload the page, the IdToken got missing from this userDetails const.

And in the console, I got this log message after reloading-

@azure/msal-common@12.0.0 : Info - CacheManager:getIdToken - No token found

After reload- Screenshot

Microsoft Security | Microsoft Entra | Microsoft Entra ID
{count} votes

2 answers

Sort by: Most helpful
  1. Alfredo Revilla - Upwork Top Talent | IAM SWE SWA 27,526 Reputation points Moderator
    2023-10-30T22:17:33.4833333+00:00

    Hello @Devesh and everybody. Apologies for the inconvenience, msal-browser@3.3.0 prevents token look-ups for tenanted authorities. Downgrading to msal-browser@3.2.0 will solve the issue while the fix gets rolled out, potentially this week.

    10/31 Update: msal-browser@3.4.0 has been released and fixes the discussed issue.

    Let us know if you need additional assistance. If the answer was helpful, please accept it and rate it so that others facing a similar issue can easily find a solution.

    3 people found this answer helpful.

  2. Arun Manohar Manoharan 1 Reputation point
    2023-10-25T20:02:22.9733333+00:00

    It seems as an issue with the latest version of the app. Try using this:

    
    

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.