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://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.