Table of Contents

Class TokenCache

Namespace
Microsoft.Identity.Client
Assembly
Microsoft.Identity.Client.dll

Token cache storing access and refresh tokens for accounts This class is used in the constructors of PublicClientApplication and ConfidentialClientApplication. In the case of ConfidentialClientApplication, two instances are used, one for the user token cache, and one for the application token cache (in the case of applications using the client credential flows).

public sealed class TokenCache : ITokenCache, ITokenCacheSerializer
Inheritance
TokenCache
Implements
Inherited Members
Extension Methods

Methods

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

public void SetAfterAccess(TokenCacheCallback afterAccess)

Parameters

afterAccess TokenCacheCallback

Delegate set in order to handle the cache serialization in the case where the HasStateChanged member of the cache is true

Remarks

In the case where the delegate is used to serialize the cache entirely (not just a row), it might want to call Serialize()

SetAfterAccessAsync(Func<TokenCacheNotificationArgs, Task>)

public void SetAfterAccessAsync(Func<TokenCacheNotificationArgs, Task> afterAccess)

Parameters

afterAccess Func<TokenCacheNotificationArgs, Task>

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

public void SetBeforeAccess(TokenCacheCallback beforeAccess)

Parameters

beforeAccess TokenCacheCallback

Delegate set in order to handle the cache deserialization

Remarks

In the case where the delegate is used to deserialize the cache, it might want to call Deserialize(byte[])

SetBeforeAccessAsync(Func<TokenCacheNotificationArgs, Task>)

public void SetBeforeAccessAsync(Func<TokenCacheNotificationArgs, Task> beforeAccess)

Parameters

beforeAccess Func<TokenCacheNotificationArgs, Task>

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)

public void SetBeforeWrite(TokenCacheCallback beforeWrite)

Parameters

beforeWrite TokenCacheCallback

Delegate set in order to prepare the cache serialization

SetBeforeWriteAsync(Func<TokenCacheNotificationArgs, Task>)

public void SetBeforeWriteAsync(Func<TokenCacheNotificationArgs, Task> beforeWrite)

Parameters

beforeWrite Func<TokenCacheNotificationArgs, Task>

SetIosKeychainSecurityGroup(string)

Sets the security group to be used with the iOS Keychain. This function should not be used by external customers. It will be removed in a future version of MSAL.

public void SetIosKeychainSecurityGroup(string securityGroup)

Parameters

securityGroup string