You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Disconnect-MgGraph does not clear the persisted MSAL token cache #3648
When a user runs Disconnect-MgGraph, the MSAL token cache persisted to disk is not cleared. Currently, LogoutAsync() only:
Clears the in-memory token cache
Nulls out the AuthContext and GraphHttpClient
Deletes the authentication record file (mg.authrecord.json)
The disk-persisted MSAL cache (used when ContextScope == CurrentUser) at %LOCALAPPDATA%\.IdentityService\mg.msal.cache.cae and mg.msal.cache.nocae remains intact. This means cached tokens survive disconnection and can be reused in subsequent sessions without re-authentication.
Expected Behavior
Running Disconnect-MgGraph should fully clear all cached authentication state, including the persisted MSAL token cache on disk, so that subsequent Connect-MgGraph calls require fresh authentication.
Current Behavior
After Disconnect-MgGraph, the persisted token cache files remain on disk. A new PowerShell session can silently reuse cached tokens without prompting for authentication.
Suggested Approach
Azure.Identity does not expose APIs to clear the persisted token cache. However, the MSAL library (Microsoft.Identity.Client.Extensions.Msal) that Azure.Identity depends on can be used directly:
Activity
fix: Clear persisted MSAL token cache on Disconnect-MgGraph (#3649)