Claims are not getting Refreshed after updating the user details attributes

NH, Prajna 0 Reputation points
2025-03-19T14:54:21.55+00:00

Post updating user details to new values in application, still token has old claims being fetched from the cache. while accessing the token . But strange behavior is sometimes it fetches right claims. Issue with Refresh token value

Also tried below changes still no luck :

var tokenAcquisitionOptions = new TokenAcquisitionOptions

{

 ForceRefresh = true // Bypass the cache and retrieve a fresh token

};

string accessToken = await _tokenAcquisition.GetAccessTokenForUserAsync(scopes , tokenAcquisitionOptions: tokenAcquisitionOptions);

We are using custom policy for Azure AD B2C for login flow

#Azure AD B2C #Redis cache

Azure Cache for Redis
Azure Cache for Redis
An Azure service that provides access to a secure, dedicated Redis cache, managed by Microsoft.
290 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Vijayalaxmi Kattimani 2,225 Reputation points Microsoft External Staff
    2025-03-19T16:43:35.5833333+00:00

    Hi NH, Prajna,

    Greetings!

    As we understand that, you are facing an issue where the token cache is not consistently updating with the new claims after user details are updated. This can be particularly tricky when using Azure AD B2C with a custom policy and Redis cache.

    Please take the following points into consideration:

    • Ensure that your Redis cache configuration is correct. If the L2 cache fails, Microsoft Identity Web will log an error but proceed with the L1 cache. You might want to handle the error as soon as possible to ensure persistence happens even if the app restarts. You can configure the MsalDistributedTokenCacheAdapterOptions to handle L2 cache failures and retry if necessary.
    • Verify that your custom policy is correctly configured to handle token refresh scenarios. Sometimes, custom policies might not be set up to force a token refresh properly.
    • Check if there are any issues with your Redis cache setup. Ensure that the cache is not experiencing connectivity issues or other problems that might prevent it from updating the token claims correctly.
    • Ensure that you are using the correct methods to acquire and cache tokens with MSAL. There are several ways to acquire a token, and some require user interaction through a web browser.

    Please refer to the below mentioned links for more information.

    https://github.com/AzureAD/microsoft-identity-web/wiki/Token-Cache-Troubleshooting

    https://stackoverflow.com/questions/78766490/id-token-in-msal-user-token-cache-is-missing-custom-claims-present-in-token-from

    https://learn.microsoft.com/en-us/entra/identity-platform/msal-acquire-cache-tokens

    I hope, This response will address your query and helped you to overcome on your challenges.

    If this answers your query, do click Accept Answer and Yes for was this answer helpful. And, if you have any further query do let us know.

    0 comments No comments

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.