Skip to content

clearing token cache

Jean-Marc Prieur edited this page May 17, 2021 · 6 revisions

Clearing the cache is achieved by removing the accounts from the cache.

This does not remove the session cookie which is in the browser, though.

The code is the following where app is a IClientApplicationBase

   // clear the cache
   var accounts = await app.GetAccountsAsync();
   while (accounts.Any())
   {
    await app.RemoveAsync(accounts.First());
    accounts = await app.GetAccountsAsync();
   }

Getting started with MSAL.NET

Acquiring tokens

Web Apps / Web APIs / daemon apps

Desktop/Mobile apps

Advanced topics

FAQ

Other resources

Clone this wiki locally