Skip to content
Introducing the next era of Duende IdentityServer. Read our CEO’s announcement

Logging

Duende Access Token Management uses the standard logging facilities provided by ASP.NET Core. You generally do not need to perform any extra configuration, as it will use the logging provider you have already configured for your application.

For log level definitions, environment guidance, and actionable next steps for each level, see the Logging Fundamentals guide.

Logs are written under the Duende.AccessTokenManagement category. To control log output for Access Token Management specifically, set that namespace in your appsettings.json:

appsettings.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Duende.AccessTokenManagement": "Debug"
}
}
}

Access Token Management emits structured log messages across several functional areas. Each message includes contextual parameters (client ID, URL, error details, etc.) for effective filtering and troubleshooting.

LevelMessageDescription
WarningCannot authenticate scheme: {Scheme} to acquire user access tokenAuthentication failed for the specified scheme
WarningAuthentication result properties are null for scheme: {Scheme} after authenticationSuccessful authentication but no token properties returned
WarningFailed to get a UserToken because no tokens found in cookie propertiesSaveTokens must be enabled for automatic token refresh
DebugStarting user token acquisitionBeginning the user token retrieval process
WarningCannot retrieve token: No active userNo authenticated user context available
WarningCannot retrieve token: No token data found in user token store for user {User}User exists but has no stored tokens
LevelMessageDescription
DebugNo refresh token found in user token store for user {User} / resource {Resource}. Returning current access tokenNo refresh token available; returning existing access token
DebugNo access token found in user token store for user {User} / resource {Resource}. Trying to refreshMissing access token; attempting refresh
DebugToken for user {User} will be refreshed. Expiration: {Expiration}, ForceRenewal: {ForceRenewal}Token refresh triggered by expiration or explicit force
TraceRefreshing access token using refresh token: hash={TokenHash}Executing refresh token grant (token hashed for security)
DebugSending Refresh token request to: {Url}HTTP request to token endpoint
DebugReturning refreshed token for user: {User}Refresh succeeded
DebugReturning current token for user: {User}Using cached token (still valid)
WarningError refreshing access token. Error = {Error}, Description: {ErrorDescription}Refresh failed with OAuth error
InformationAccess Token of type {TokenType} refreshed with expiration: {Expiration}Successful refresh with new expiration
LevelMessageDescription
TraceRevoking refresh token: hash={TokenHash}Starting revocation (token hashed)
DebugSending Token revocation request to: {Url}HTTP request to revocation endpoint
WarningError revoking refresh token. Error = {Error}Revocation failed
LevelMessageDescription
DebugRequesting client credentials access token at endpoint: {Url}Starting client credentials grant
InformationClient Credentials token of type {TokenType} for Client: {ClientName} retrieved with expiration {Expiration}Token successfully obtained
WarningError requesting access token for client {ClientName}. Error = {Error}, Description: {ErrorDescription}Token request failed
DebugCaching access token for client: {ClientName}. Expiration: {Expiration}Storing token in cache
DebugCache hit for obtaining access token for client: {ClientName}Using cached token
DebugCache miss while retrieving access token for client: {ClientName}No cached token; fetching new one
WarningWill not cache token result with error for {ClientName}. Error = {Error}, Description: {ErrorDescription}Skipping cache for failed token
WarningAn exception has occurred while reading ClientCredentialsToken value from the cache for client {ClientName}Cache read error; falling back to fetch
WarningError trying to set token in cache for client {ClientName}Cache write failed
WarningError parsing cached access token for client {ClientName}Cached value was corrupted
WarningFailed to obtain token from cache for client {ClientName} using cacheKey {CacheKey}. Will obtain new tokenCache retrieval failed; fetching new token

These messages are emitted by AccessTokenRequestHandler when sending HTTP requests with tokens:

LevelMessageDescription
DebugSending Access token of type {TokenType} to endpoint: {Url}Attaching token to outgoing request
WarningFailed to obtain an access token while sending the request. Error: {Error}, ErrorDescription {ErrorDescription}Could not get token; request sent without authentication
WarningWhile sending a request, received UnAuthorized after acquiring a new access tokenFresh token was rejected by the resource server
DebugToken not accepted while sending request. Retrying with new access token401 response triggered token refresh and retry
LevelMessageDescription
DebugCreating DPoP proof token for token requestGenerating DPoP proof for token endpoint
DebugSending DPoP proof token in request to endpoint: {Url}Attaching DPoP proof to request
DebugFailed to create DPoP proof token for request to endpoint: {Url}DPoP proof generation failed; falling back to Bearer
DebugThe authorization server has supplied a new nonce on a successful responseServer-provided nonce stored for future requests
DebugDPoP nonce error: {Error}. Retrying using new nonceRetrying with server-provided nonce
DebugDPoP error {Error} during token refresh. Retrying with server nonceNonce error during refresh; retrying
WarningFailed to get DPoP Nonce because server didn’t respond with ok. StatusCode was: {StatusCode}Nonce request failed
TraceCache hit for DPoP nonce for URL: {Url}, method: {Method}Using cached nonce
TraceWriting DPoP nonce to Cache for URL: {Url}, method: {Method}. Expiration: {Expiration}Storing nonce in cache
TraceCache miss for DPoP nonce for URL: {Url}, method: {Method}No cached nonce available
WarningFailed to parse the cached Nonce {Value} for URL: {Url}, method: {Method}. Error: {Error}Cached nonce was invalid
LevelMessageDescription
WarningFailed to parse JsonWebKeyJWK parsing failed
WarningFailed to create thumbprint from JSON web keyCould not compute key thumbprint

Access Token Management supports OpenTelemetry for distributed tracing and metrics collection.

The library emits traces under the activity source Duende.AccessTokenManagement. Add this to your OpenTelemetry configuration:

builder.Services.AddOpenTelemetry()
.WithTracing(tracing => tracing
.AddSource("Duende.AccessTokenManagement")
// ... other sources
);

Activity spans:

NameDescription
Duende.AccessTokenManagement.AcquiringTokenWraps the entire token acquisition operation

Metrics are exposed under the meter Duende.AccessTokenManagement:

builder.Services.AddOpenTelemetry()
.WithMetrics(metrics => metrics
.AddMeter("Duende.AccessTokenManagement")
// ... other meters
);

Available counters:

CounterDescriptionTags
access_token_usedNumber of times an access token was usedClientId, TokenType
token_retrievedNumber of times a token was retrieved from the token endpointClientId, TokenType
token_retrieval_failedNumber of times token retrieval failedClientId, TokenType, Error
token_send_retryNumber of times a token was rejected and retriedClientId
dpop_nonce_error_retryNumber of times a DPoP nonce error triggered a retryClientId, Error

The TokenType tag distinguishes between ClientCredentials and User token flows.