<PackageReference Include="Microsoft.Identity.Client" Version="4.86.1-azure-arc-preview" />

Microsoft.Identity.Client.TokenCacheNotificationArgs

public sealed class TokenCacheNotificationArgs
Contains parameters used by the MSAL call accessing the cache. See also ITokenCacheSerializer which contains methods to customize the cache serialization. For more details about the token cache see https://aka.ms/msal-net-web-token-cache
public IAccount Account { get; }

Gets the account involved in the cache transaction.

The cancellation token that was passed to AcquireToken* flow via ExecuteAsync(CancellationToken). Can be passed along to the custom token cache implementation.

public string ClientId { get; }

Gets the ClientId (application ID) of the application involved in the cache transaction

public Guid CorrelationId { get; }

The correlation id associated with the request. See WithCorrelationId

public bool HasStateChanged { get; }

Indicates whether the state of the cache has changed, for example when tokens are being added or removed. Not all cache operations modify the state of the cache.

public bool HasTokens { get; }

Is true when at least one non-expired access token exists in the cache.

public IIdentityLogger IdentityLogger { get; }

Identity Logger provided at the time of application creation Via WithLogging(IIdentityLogger, bool)/> Calling the log function will automatically add MSAL formatting to the message. For details see https://aka.ms/msal-net-logging

public bool IsApplicationCache { get; }

Indicates whether the cache change occurred in the UserTokenCache or in the AppTokenCache.

public string NoDistributedCacheUseReason { get; }

Determines whether the client application authentication instance is classified as an FMI (Federated Managed Identity) node under a specified RMA (Resource Managed Authority).

public bool PiiLoggingEnabled { get; }

Boolean used to determine if Personally Identifiable Information (PII) logging is enabled.

public IEnumerable<string> RequestScopes { get; }

Scopes specified in the AcquireToken* method.

public string RequestTenantId { get; }

Tenant Id specified in the AcquireToken* method, if any.

Suggested value of the expiry, to help determining the cache eviction time. This value is only set on the OnAfterAccess delegate, on a cache write operation (that is when args.HasStateChanged is true) and when the cache node contains only access tokens. In all other cases it's null.

public string SuggestedCacheKey { get; }

A suggested token cache key, which can be used with general purpose storage mechanisms that allow storing key-value pairs and key based retrieval. Useful in applications that store one token cache per user, the recommended pattern for web apps. The value is: homeAccountId for AcquireTokenSilent, GetAccount(homeAccountId), RemoveAccount and when writing tokens on confidential client calls"{clientId}__AppTokenCache" for AcquireTokenForClient"{clientId}_{tenantId}_AppTokenCache" for AcquireTokenForClient when using a tenant specific authoritythe hash of the original token for AcquireTokenOnBehalfOf

public TelemetryData TelemetryData { get; }

Cache Details contains the details of L1/ L2 cache for telemetry logging.

Gets the ITokenCacheSerializer involved in the transaction

public TokenCacheNotificationArgs(ITokenCacheSerializer tokenCache, string clientId, IAccount account, bool hasStateChanged, bool isApplicationCache, string suggestedCacheKey, bool hasTokens, DateTimeOffset? suggestedCacheExpiry, CancellationToken cancellationToken)

This constructor is for test purposes only. It allows apps to unit test their MSAL token cache implementation code.

public TokenCacheNotificationArgs(ITokenCacheSerializer tokenCache, string clientId, IAccount account, bool hasStateChanged, bool isApplicationCache, string suggestedCacheKey, bool hasTokens, DateTimeOffset? suggestedCacheExpiry, CancellationToken cancellationToken, Guid correlationId)

This constructor is for test purposes only. It allows apps to unit test their MSAL token cache implementation code.

public TokenCacheNotificationArgs(ITokenCacheSerializer tokenCache, string clientId, IAccount account, bool hasStateChanged, bool isApplicationCache, string suggestedCacheKey, bool hasTokens, DateTimeOffset? suggestedCacheExpiry, CancellationToken cancellationToken, Guid correlationId, IEnumerable<string> requestScopes, string requestTenantId)

This constructor is for test purposes only. It allows apps to unit test their MSAL token cache implementation code.

public TokenCacheNotificationArgs(ITokenCacheSerializer tokenCache, string clientId, IAccount account, bool hasStateChanged, bool isApplicationCache, string suggestedCacheKey, bool hasTokens, DateTimeOffset? suggestedCacheExpiry, CancellationToken cancellationToken, Guid correlationId, IEnumerable<string> requestScopes, string requestTenantId, IIdentityLogger identityLogger, bool piiLoggingEnabled, TelemetryData telemetryData = null)

This constructor is for test purposes only. It allows apps to unit test their MSAL token cache implementation code.