[Feature Request] Provide a way of clearing the in-memory token cache for a ConfidentialClientApplication
See original GitHub issueSometimes an application might be updated on Azure to have more permissions added to it, when this happens, if a token is already cached by my ConfidentialClientApplication
, there is no way (that I know of) to remove a token that is already cached, to force a “refresh”. So all the subsequent requests to my resource will return 403 until the token expires from cache and a new one is obtained.
I tried using the GetAccountsAsync
method documented here, but, even though it doesn’t explicitly say anything regarding this, it only handles user tokens.
There should be a way to force clearing the token cache. The way I see this getting implemented in my application is having a retry policy that tries to obtain a new token whenever a call to my resource returns 403, to make sure my token is refreshed.
I see a few ways this could be possible:
- Getting something like the “AppAccounts” so I can manually remove them.
- Clearing the cache explicitly
- Having a way to force a bypass from cache when requesting a new token (
AcquireTokenForClient
).
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top GitHub Comments
Thanks @akamud - I created a docs PR for this https://github.com/MicrosoftDocs/azure-docs/pull/95763
Did you try the
.WithForceRefresh(true)
call on the builder retruned by app.AcquireTokenXXX() methods?\