Dela via


ITokenCache Interface

Definition

This is the interface that implements the public access to cache operations. With CacheV2, this should only be necessary if the caller is persisting the cache in their own store, since this will provide the serialize/deserialize and before/after notifications used in that scenario. See https://aka.ms/aka.ms/msal-net-token-cache-serialization

public interface ITokenCache
type ITokenCache = interface
Public Interface ITokenCache
Derived

Methods

Deserialize(Byte[])
Obsolete.

Functionality replaced by DeserializeMsalV2(Byte[]). See https://aka.ms/msal-net-4x-cache-breaking-change ///

DeserializeAdalV3(Byte[])
Obsolete.

Functionality replaced by DeserializeAdalV3(Byte[]) and is accessible in TokenCacheNotificationArgs. See https://aka.ms/msal-net-4x-cache-breaking-change

DeserializeMsalV2(Byte[])
Obsolete.

Functionality replaced by DeserializeMsalV2(Byte[]) and is accessible in TokenCacheNotificationArgs.

DeserializeMsalV3(Byte[], Boolean)
Obsolete.

Functionality replaced by DeserializeMsalV3(Byte[], Boolean) and is accessible in TokenCacheNotificationArgs.

DeserializeUnifiedAndAdalCache(CacheData)
Obsolete.

Functionality replaced by DeserializeMsalV2(Byte[]) and DeserializeAdalV3(Byte[]) See https://aka.ms/msal-net-4x-cache-breaking-change

Serialize()
Obsolete.

Functionality replaced by SerializeMsalV2(). See https://aka.ms/msal-net-4x-cache-breaking-change ///

SerializeAdalV3()
Obsolete.

Functionality replaced by SerializeAdalV3() and is accessible in TokenCacheNotificationArgs.

SerializeMsalV2()
Obsolete.

Functionality replaced by SerializeMsalV2() and is accessible in TokenCacheNotificationArgs.

SerializeMsalV3()
Obsolete.

Functionality replaced by SerializeMsalV3() and is accessible in TokenCacheNotificationArgs.

SerializeUnifiedAndAdalCache()
Obsolete.

Functionality replaced by SerializeMsalV2() and SerializeAdalV3() See https://aka.ms/msal-net-4x-cache-breaking-change

SetAfterAccess(TokenCacheCallback)

Sets a delegate to be notified after any library method accesses the cache. This gives an option to the delegate to serialize a cache entry for the application and accounts specified in the TokenCacheNotificationArgs. See https://aka.ms/msal-net-token-cache-serialization. If you need async/task-based callbacks, please use SetAfterAccessAsync instead.

SetAfterAccessAsync(Func<TokenCacheNotificationArgs,Task>)

Sets a delegate to be notified after any library method accesses the cache. This gives an option to the delegate to serialize a cache entry for the application and accounts specified in the TokenCacheNotificationArgs. See https://aka.ms/msal-net-token-cache-serialization. This provides the same functionality as SetAfterAccess but it provides for an async/task-based callback.

SetBeforeAccess(TokenCacheCallback)

Sets a delegate to be notified before any library method accesses the cache. This gives an option to the delegate to deserialize a cache entry for the application and accounts specified in the TokenCacheNotificationArgs. See https://aka.ms/msal-net-token-cache-serialization. If you need async/task-based callbacks, please use SetBeforeAccessAsync instead.

SetBeforeAccessAsync(Func<TokenCacheNotificationArgs,Task>)

Sets a delegate to be notified before any library method accesses the cache. This gives an option to the delegate to deserialize a cache entry for the application and accounts specified in the TokenCacheNotificationArgs. See https://aka.ms/msal-net-token-cache-serialization. This provides the same functionality as SetBeforeAccess but it provides for an async/task-based callback.

SetBeforeWrite(TokenCacheCallback)

Sets a delegate called before any library method writes to the cache. This gives an option to the delegate to reload the cache state from a row in database and lock that row. That database row can then be unlocked in the delegate registered with SetAfterAccess(TokenCacheCallback) If you need async/task-based callbacks, please use SetBeforeWriteAsync instead.

SetBeforeWriteAsync(Func<TokenCacheNotificationArgs,Task>)

Sets a delegate called before any library method writes to the cache. This gives an option to the delegate to reload the cache state from a row in database and lock that row. That database row can then be unlocked in the delegate registered with SetAfterAccess(TokenCacheCallback) This provides the same functionality as SetBeforeWrite but it provides for an async/task-based callback.

Extension Methods

SetCacheOptions(ITokenCache, CacheOptions)

Options for MSAL token caches.

MSAL maintains a token cache internally in memory. By default, this cache object is part of each instance of PublicClientApplication or ConfidentialClientApplication. This method allows customization of the in-memory token cache of MSAL.

MSAL's memory cache is different than token cache serialization. Cache serialization pulls the tokens from a cache (e.g. Redis, Cosmos, or a file on disk), where they are stored in JSON format, into MSAL's internal memory cache. Memory cache operations do not involve JSON operations.

External cache serialization remains the recommended way to handle desktop apps, web site and web APIs, as it provides persistence. These options do not currently control external cache serialization.

Detailed guidance for each application type and platform: https://aka.ms/msal-net-token-cache-serialization

Applies to