Table of Contents

Interface IIdentityServerTools

Namespace
Duende.IdentityServer
Assembly
Duende.IdentityServer.dll

Useful helpers for interacting with IdentityServer.

public interface IIdentityServerTools

Methods

IssueClientJwtAsync(string, int, IEnumerable<string>?, IEnumerable<string>?, IEnumerable<Claim>?)

Issues a JWT access token for a particular client.

Task<string> IssueClientJwtAsync(string clientId, int lifetime, IEnumerable<string>? scopes = null, IEnumerable<string>? audiences = null, IEnumerable<Claim>? additionalClaims = null)

Parameters

clientId string

The client identifier, set in the client_id claim.

lifetime int

The lifetime, in seconds, which will determine the exp claim of the token.

scopes IEnumerable<string>

A collection of scopes, which will be added to the token as claims with the "scope" type.

audiences IEnumerable<string>

A collection of audiences, which will be added to the token as claims with the "aud" type.

additionalClaims IEnumerable<Claim>

A collection of additional claims to include in the token.

Returns

Task<string>

A JWT with the specified client, lifetime, scopes, audiences, and additional claims.

Remarks

Typical implementations depend on the HttpContext or IssuerUri to determine the issuer of the token. Ensure that calls to this method will only occur if there is an incoming HTTP request or with the option set.

IssueJwtAsync(int, IEnumerable<Claim>)

Issues a JWT with a specific lifetime and set of claims.

Task<string> IssueJwtAsync(int lifetime, IEnumerable<Claim> claims)

Parameters

lifetime int

The lifetime, in seconds, which will determine the exp claim of the token.

claims IEnumerable<Claim>

A collection of additional claims to include in the token.

Returns

Task<string>

A JWT that expires after the specified lifetime and contains the given claims.

Remarks

Typical implementations depend on the HttpContext or IssuerUri to determine the issuer of the token. Ensure that calls to this method will only occur if there is an incoming HTTP request or with the option set.

IssueJwtAsync(int, string, IEnumerable<Claim>)

Issues a JWT with a specific lifetime, issuer, and set of claims.

Task<string> IssueJwtAsync(int lifetime, string issuer, IEnumerable<Claim> claims)

Parameters

lifetime int

The lifetime, in seconds, which will determine the exp claim of the token.

issuer string

The issuer of the token, set in the iss claim.

claims IEnumerable<Claim>

A collection of additional claims to include in the token.

Returns

Task<string>

A JWT with the specified lifetime, issuer and additional claims.

IssueJwtAsync(int, string, string, IEnumerable<Claim>)

Issues a JWT with a specific lifetime, issuer, token type, and set of claims.

Task<string> IssueJwtAsync(int lifetime, string issuer, string tokenType, IEnumerable<Claim> claims)

Parameters

lifetime int

The lifetime, in seconds, which will determine the exp claim of the token.

issuer string

The issuer of the token, set in the iss claim.

tokenType string

The token's type, such as "access_token" or "id_token", set in the typ claim.

claims IEnumerable<Claim>

A collection of additional claims to include in the token.

Returns

Task<string>

A JWT with the specified lifetime, issuer, token type, and additional claims.