<PackageReference Include="Microsoft.Identity.Client.Extensions.Msal" Version="4.84.2-preview" />

Microsoft.Identity.Client.Extensions.Msal.MsalCacheHelper

public class MsalCacheHelper
Helper to create the token cache
public const string LinuxKeyRingDefaultCollection = "default"

The name of the Default KeyRing collection. Secrets stored in this collection are persisted to disk

public const string LinuxKeyRingSessionCollection = "session"

The name of the Session KeyRing collection. Secrets stored in this collection are not persisted to disk, but will be available for the duration of the user session.

public static string UserRootDirectory { get; }

Gets the user's root directory across platforms.

Allows clients to listen for cache updates originating from disk.

public static Task<MsalCacheHelper> CreateAsync(StorageCreationProperties storageCreationProperties, TraceSource logger = null)

Creates a new instance of MsalCacheHelper. To configure MSAL to use this cache persistence, call RegisterCache

public void Clear()

Clears the token store. Equivalent to a delete operation on the persistence layer (file delete).

public byte[] LoadUnencryptedTokenCache()

Extracts the token cache data from the persistent store

public void RegisterCache(ITokenCache tokenCache)

Registers a token cache to synchronize with the persistent storage.

public void SaveUnencryptedTokenCache(byte[] tokenCache)

Saves an unencrypted, UTF-8 encoded byte array representing an MSAL token cache. The save operation will persist the data in a secure location, as configured in StorageCreationProperties

public void UnregisterCache(ITokenCache tokenCache)

Unregisters a token cache so it no longer synchronizes with on disk storage.

public void VerifyPersistence()

Performs a write -> read -> clear using the underlying persistence mechanism and throws an MsalCachePersistenceException if something goes wrong.