Version 5.x has been out of support since December 13, 2022, and this corresponding section of the documentation is no longer maintained. We strongly recommend upgrading to a supported version.

Custom Token Request Validator

Duende.IdentityServer.Validation.ICustomTokenRequestValidator

Allows running custom code as part of the token issuance pipeline at the token endpoint.

/// <summary>
/// Allows inserting custom validation logic into token requests
/// </summary>
public interface ICustomTokenRequestValidator
{
    /// <summary>
    /// Custom validation logic for a token request.
    /// </summary>
    /// <param name="context">The context.</param>
    /// <returns>
    /// The validation result
    /// </returns>
    Task ValidateAsync(CustomTokenRequestValidationContext context);
}
  • ValidateAsync

    This method gets called during token request processing. The context gives you access to request and response parameters.

    You can also change certain parameters on the validated request object, e.g. the token lifetime, toke type, confirmation method and client claims.

    The CustomResponse dictionary allows emitting additional response fields.