Condividi tramite


TokenCacheNotificationArgs Class

Definition

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 sealed class TokenCacheNotificationArgs
type TokenCacheNotificationArgs = class
Public NotInheritable Class TokenCacheNotificationArgs
Inheritance
TokenCacheNotificationArgs

Constructors

TokenCacheNotificationArgs(ITokenCacheSerializer, String, IAccount, Boolean, Boolean, String, Boolean, Nullable<DateTimeOffset>, CancellationToken, Guid, IEnumerable<String>, String, IIdentityLogger, Boolean, TelemetryData)

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

TokenCacheNotificationArgs(ITokenCacheSerializer, String, IAccount, Boolean, Boolean, String, Boolean, Nullable<DateTimeOffset>, CancellationToken, Guid, IEnumerable<String>, String)

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

TokenCacheNotificationArgs(ITokenCacheSerializer, String, IAccount, Boolean, Boolean, String, Boolean, Nullable<DateTimeOffset>, CancellationToken, Guid)

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

TokenCacheNotificationArgs(ITokenCacheSerializer, String, IAccount, Boolean, Boolean, String, Boolean, Nullable<DateTimeOffset>, CancellationToken)

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

Properties

Account

Gets the account involved in the cache transaction.

CancellationToken

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

ClientId

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

CorrelationId

The correlation id associated with the request. See WithCorrelationId(Guid)

HasStateChanged

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.

HasTokens

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

IdentityLogger

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

IsApplicationCache

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

PiiLoggingEnabled

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

RequestScopes

Scopes specified in the AcquireToken* method.

RequestTenantId

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

SuggestedCacheExpiry

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.

SuggestedCacheKey

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 authority
  • the hash of the original token for AcquireTokenOnBehalfOf
TelemetryData

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

TokenCache

Gets the ITokenCacheSerializer involved in the transaction

User
Obsolete.

In MSAL.NET 1.x, returned the user who signed in to get the authentication result. From MSAL 2.x rather use Account instead. See https://aka.ms/msal-net-2-released for more details.

Applies to