Table of Contents

Class OpenIddictExtensions

Namespace
OpenIddict.Abstractions
Assembly
OpenIddict.Abstractions.dll

Provides extension methods to make OpenIddictRequest and OpenIddictResponse easier to work with.

public static class OpenIddictExtensions
Inheritance
OpenIddictExtensions
Inherited Members

Methods

AddClaim(ClaimsIdentity, string, bool)

Adds a claim to a given identity.

public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, bool value)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value bool

The value associated with the claim.

Returns

ClaimsIdentity

AddClaim(ClaimsIdentity, string, bool, string)

Adds a claim to a given identity.

public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, bool value, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value bool

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsIdentity

AddClaim(ClaimsIdentity, string, IDictionary<string, string?>)

Adds a claim to a given identity.

public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, IDictionary<string, string?> value)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value IDictionary<string, string>

The value associated with the claim.

Returns

ClaimsIdentity

AddClaim(ClaimsIdentity, string, IDictionary<string, string?>, string)

Adds a claim to a given identity.

public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, IDictionary<string, string?> value, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value IDictionary<string, string>

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsIdentity

AddClaim(ClaimsIdentity, string, long)

Adds a claim to a given identity.

public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, long value)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value long

The value associated with the claim.

Returns

ClaimsIdentity

AddClaim(ClaimsIdentity, string, long, string)

Adds a claim to a given identity.

public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, long value, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value long

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsIdentity

AddClaim(ClaimsIdentity, string, string)

Adds a claim to a given identity.

public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value string

The value associated with the claim.

Returns

ClaimsIdentity

AddClaim(ClaimsIdentity, string, string, string)

Adds a claim to a given identity.

public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, string value, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value string

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsIdentity

AddClaim(ClaimsIdentity, string, JsonElement)

Adds a claim to a given identity.

public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, JsonElement value)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value JsonElement

The value associated with the claim.

Returns

ClaimsIdentity

AddClaim(ClaimsIdentity, string, JsonElement, string)

Adds a claim to a given identity.

public static ClaimsIdentity AddClaim(this ClaimsIdentity identity, string type, JsonElement value, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value JsonElement

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsIdentity

AddClaim(ClaimsPrincipal, string, bool)

Adds a claim to a given principal.

public static ClaimsPrincipal AddClaim(this ClaimsPrincipal principal, string type, bool value)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value bool

The value associated with the claim.

Returns

ClaimsPrincipal

AddClaim(ClaimsPrincipal, string, bool, string)

Adds a claim to a given principal.

public static ClaimsPrincipal AddClaim(this ClaimsPrincipal principal, string type, bool value, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value bool

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsPrincipal

AddClaim(ClaimsPrincipal, string, IDictionary<string, string?>)

Adds a claim to a given principal.

public static ClaimsPrincipal AddClaim(this ClaimsPrincipal principal, string type, IDictionary<string, string?> value)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value IDictionary<string, string>

The value associated with the claim.

Returns

ClaimsPrincipal

AddClaim(ClaimsPrincipal, string, IDictionary<string, string?>, string)

Adds a claim to a given principal.

public static ClaimsPrincipal AddClaim(this ClaimsPrincipal principal, string type, IDictionary<string, string?> value, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value IDictionary<string, string>

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsPrincipal

AddClaim(ClaimsPrincipal, string, long)

Adds a claim to a given principal.

public static ClaimsPrincipal AddClaim(this ClaimsPrincipal principal, string type, long value)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value long

The value associated with the claim.

Returns

ClaimsPrincipal

AddClaim(ClaimsPrincipal, string, long, string)

Adds a claim to a given principal.

public static ClaimsPrincipal AddClaim(this ClaimsPrincipal principal, string type, long value, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value long

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsPrincipal

AddClaim(ClaimsPrincipal, string, string)

Adds a claim to a given principal.

public static ClaimsPrincipal AddClaim(this ClaimsPrincipal principal, string type, string value)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value string

The value associated with the claim.

Returns

ClaimsPrincipal

AddClaim(ClaimsPrincipal, string, string, string)

Adds a claim to a given principal.

public static ClaimsPrincipal AddClaim(this ClaimsPrincipal principal, string type, string value, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value string

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsPrincipal

AddClaim(ClaimsPrincipal, string, JsonElement)

Adds a claim to a given principal.

public static ClaimsPrincipal AddClaim(this ClaimsPrincipal principal, string type, JsonElement value)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value JsonElement

The value associated with the claim.

Returns

ClaimsPrincipal

AddClaim(ClaimsPrincipal, string, JsonElement, string)

Adds a claim to a given principal.

public static ClaimsPrincipal AddClaim(this ClaimsPrincipal principal, string type, JsonElement value, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value JsonElement

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsPrincipal

AddClaims(ClaimsIdentity, string, ImmutableArray<string>)

Adds claims to a given identity.

public static ClaimsIdentity AddClaims(this ClaimsIdentity identity, string type, ImmutableArray<string> values)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claims.

values ImmutableArray<string>

The values associated with the claims.

Returns

ClaimsIdentity

AddClaims(ClaimsIdentity, string, ImmutableArray<string>, string)

Adds claims to a given identity.

public static ClaimsIdentity AddClaims(this ClaimsIdentity identity, string type, ImmutableArray<string> values, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claims.

values ImmutableArray<string>

The values associated with the claims.

issuer string

The issuer associated with the claims.

Returns

ClaimsIdentity

AddClaims(ClaimsIdentity, string, JsonElement)

Adds claims to a given identity.

public static ClaimsIdentity AddClaims(this ClaimsIdentity identity, string type, JsonElement value)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claims.

value JsonElement

The value associated with the claims.

Returns

ClaimsIdentity

AddClaims(ClaimsIdentity, string, JsonElement, string)

Adds claims to a given identity.

public static ClaimsIdentity AddClaims(this ClaimsIdentity identity, string type, JsonElement value, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claims.

value JsonElement

The value associated with the claims.

issuer string

The issuer associated with the claims.

Returns

ClaimsIdentity

AddClaims(ClaimsPrincipal, string, ImmutableArray<string>)

Adds claims to a given principal.

public static ClaimsPrincipal AddClaims(this ClaimsPrincipal principal, string type, ImmutableArray<string> values)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claims.

values ImmutableArray<string>

The values associated with the claims.

Returns

ClaimsPrincipal

AddClaims(ClaimsPrincipal, string, ImmutableArray<string>, string)

Adds claims to a given principal.

public static ClaimsPrincipal AddClaims(this ClaimsPrincipal principal, string type, ImmutableArray<string> values, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claims.

values ImmutableArray<string>

The values associated with the claims.

issuer string

The issuer associated with the claims.

Returns

ClaimsPrincipal

AddClaims(ClaimsPrincipal, string, JsonElement)

Adds claims to a given principal.

public static ClaimsPrincipal AddClaims(this ClaimsPrincipal principal, string type, JsonElement value)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claims.

value JsonElement

The value associated with the claims.

Returns

ClaimsPrincipal

AddClaims(ClaimsPrincipal, string, JsonElement, string)

Adds claims to a given principal.

public static ClaimsPrincipal AddClaims(this ClaimsPrincipal principal, string type, JsonElement value, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claims.

value JsonElement

The value associated with the claims.

issuer string

The issuer associated with the claims.

Returns

ClaimsPrincipal

Clone(ClaimsIdentity, Func<Claim, bool>)

Clones an identity by filtering its claims and the claims of its actor, recursively.

public static ClaimsIdentity Clone(this ClaimsIdentity identity, Func<Claim, bool> filter)

Parameters

identity ClaimsIdentity

The ClaimsIdentity instance to filter.

filter Func<Claim, bool>

The delegate filtering the claims: return true to accept the claim, false to remove it.

Returns

ClaimsIdentity

Clone(ClaimsPrincipal, Func<Claim, bool>)

Clones a principal by filtering its identities.

public static ClaimsPrincipal Clone(this ClaimsPrincipal principal, Func<Claim, bool> filter)

Parameters

principal ClaimsPrincipal

The ClaimsPrincipal instance to filter.

filter Func<Claim, bool>

The delegate filtering the claims: return true to accept the claim, false to remove it.

Returns

ClaimsPrincipal

GetAccessTokenLifetime(ClaimsIdentity)

Gets the access token lifetime associated with the claims identity.

public static TimeSpan? GetAccessTokenLifetime(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

TimeSpan?

The access token lifetime or null if the claim cannot be found.

GetAccessTokenLifetime(ClaimsPrincipal)

Gets the access token lifetime associated with the claims principal.

public static TimeSpan? GetAccessTokenLifetime(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

TimeSpan?

The access token lifetime or null if the claim cannot be found.

GetAcrValues(OpenIddictRequest)

Extracts the authentication context class values from an OpenIddictRequest.

public static ImmutableArray<string> GetAcrValues(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

ImmutableArray<string>

GetAudiences(ClaimsIdentity)

Gets the audiences list stored in the claims identity.

public static ImmutableArray<string> GetAudiences(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

ImmutableArray<string>

The audiences list or an empty set if the claims cannot be found.

GetAudiences(ClaimsPrincipal)

Gets the audiences list stored in the claims principal.

public static ImmutableArray<string> GetAudiences(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

ImmutableArray<string>

The audiences list or an empty set if the claims cannot be found.

GetAuthorizationCodeLifetime(ClaimsIdentity)

Gets the authorization code lifetime associated with the claims identity.

public static TimeSpan? GetAuthorizationCodeLifetime(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

TimeSpan?

The authorization code lifetime or null if the claim cannot be found.

GetAuthorizationCodeLifetime(ClaimsPrincipal)

Gets the authorization code lifetime associated with the claims principal.

public static TimeSpan? GetAuthorizationCodeLifetime(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

TimeSpan?

The authorization code lifetime or null if the claim cannot be found.

GetAuthorizationId(ClaimsIdentity)

Gets the internal authorization identifier associated with the claims identity.

public static string? GetAuthorizationId(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

string

The unique identifier or null if the claim cannot be found.

GetAuthorizationId(ClaimsPrincipal)

Gets the internal authorization identifier associated with the claims principal.

public static string? GetAuthorizationId(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

string

The unique identifier or null if the claim cannot be found.

GetClaim(ClaimsIdentity, string)

Gets the unique claim value corresponding to the given type.

public static string? GetClaim(this ClaimsIdentity identity, string type)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

Returns

string

The claim value.

Exceptions

InvalidOperationException

Multiple claims using the same type are present in the identity.

GetClaim(ClaimsPrincipal, string)

Gets the unique claim value corresponding to the given type.

public static string? GetClaim(this ClaimsPrincipal principal, string type)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

Returns

string

The claim value.

Exceptions

InvalidOperationException

Multiple claims using the same type are present in the principal.

GetClaims(ClaimsIdentity, string)

Gets all the claim values corresponding to the given type.

public static ImmutableArray<string> GetClaims(this ClaimsIdentity identity, string type)

Parameters

identity ClaimsIdentity

The claims identity.

type string

The type associated with the claims.

Returns

ImmutableArray<string>

The claim values.

GetClaims(ClaimsPrincipal, string)

Gets all the claim values corresponding to the given type.

public static ImmutableArray<string> GetClaims(this ClaimsPrincipal principal, string type)

Parameters

principal ClaimsPrincipal

The claims principal.

type string

The type associated with the claims.

Returns

ImmutableArray<string>

The claim values.

GetCreationDate(ClaimsIdentity)

Gets the creation date stored in the claims identity.

public static DateTimeOffset? GetCreationDate(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

DateTimeOffset?

The creation date or null if the claim cannot be found.

GetCreationDate(ClaimsPrincipal)

Gets the creation date stored in the claims principal.

public static DateTimeOffset? GetCreationDate(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

DateTimeOffset?

The creation date or null if the claim cannot be found.

GetDestinations(Claim)

Gets the destinations associated with a claim.

public static ImmutableArray<string> GetDestinations(this Claim claim)

Parameters

claim Claim

The Claim instance.

Returns

ImmutableArray<string>

The destinations associated with the claim.

GetDestinations(ClaimsIdentity)

Gets the destinations associated with all the claims of the given identity.

public static ImmutableDictionary<string, string[]> GetDestinations(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The identity.

Returns

ImmutableDictionary<string, string[]>

The destinations, returned as a flattened dictionary.

GetDestinations(ClaimsPrincipal)

Gets the destinations associated with all the claims of the given principal.

public static ImmutableDictionary<string, string[]> GetDestinations(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The principal.

Returns

ImmutableDictionary<string, string[]>

The destinations, returned as a flattened dictionary.

GetDeviceCodeLifetime(ClaimsIdentity)

Gets the device code lifetime associated with the claims identity.

public static TimeSpan? GetDeviceCodeLifetime(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

TimeSpan?

The device code lifetime or null if the claim cannot be found.

GetDeviceCodeLifetime(ClaimsPrincipal)

Gets the device code lifetime associated with the claims principal.

public static TimeSpan? GetDeviceCodeLifetime(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

TimeSpan?

The device code lifetime or null if the claim cannot be found.

GetExpirationDate(ClaimsIdentity)

Gets the expiration date stored in the claims identity.

public static DateTimeOffset? GetExpirationDate(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

DateTimeOffset?

The expiration date or null if the claim cannot be found.

GetExpirationDate(ClaimsPrincipal)

Gets the expiration date stored in the claims principal.

public static DateTimeOffset? GetExpirationDate(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

DateTimeOffset?

The expiration date or null if the claim cannot be found.

GetIdentityTokenLifetime(ClaimsIdentity)

Gets the identity token lifetime associated with the claims identity.

public static TimeSpan? GetIdentityTokenLifetime(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

TimeSpan?

The identity token lifetime or null if the claim cannot be found.

GetIdentityTokenLifetime(ClaimsPrincipal)

Gets the identity token lifetime associated with the claims principal.

public static TimeSpan? GetIdentityTokenLifetime(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

TimeSpan?

The identity token lifetime or null if the claim cannot be found.

GetPresenters(ClaimsIdentity)

Gets the presenters list stored in the claims identity.

public static ImmutableArray<string> GetPresenters(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

ImmutableArray<string>

The presenters list or an empty set if the claims cannot be found.

GetPresenters(ClaimsPrincipal)

Gets the presenters list stored in the claims principal.

public static ImmutableArray<string> GetPresenters(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

ImmutableArray<string>

The presenters list or an empty set if the claims cannot be found.

GetPrompts(OpenIddictRequest)

Extracts the prompt values from an OpenIddictRequest.

public static ImmutableArray<string> GetPrompts(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

ImmutableArray<string>

GetRefreshTokenLifetime(ClaimsIdentity)

Gets the refresh token lifetime associated with the claims identity.

public static TimeSpan? GetRefreshTokenLifetime(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

TimeSpan?

The refresh token lifetime or null if the claim cannot be found.

GetRefreshTokenLifetime(ClaimsPrincipal)

Gets the refresh token lifetime associated with the claims principal.

public static TimeSpan? GetRefreshTokenLifetime(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

TimeSpan?

The refresh token lifetime or null if the claim cannot be found.

GetResources(ClaimsIdentity)

Gets the resources list stored in the claims identity.

public static ImmutableArray<string> GetResources(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

ImmutableArray<string>

The resources list or an empty set if the claims cannot be found.

GetResources(ClaimsPrincipal)

Gets the resources list stored in the claims principal.

public static ImmutableArray<string> GetResources(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

ImmutableArray<string>

The resources list or an empty set if the claims cannot be found.

GetResponseTypes(OpenIddictRequest)

Extracts the response types from an OpenIddictRequest.

public static ImmutableArray<string> GetResponseTypes(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

ImmutableArray<string>

GetScopes(OpenIddictRequest)

Extracts the scopes from an OpenIddictRequest.

public static ImmutableArray<string> GetScopes(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

ImmutableArray<string>

GetScopes(ClaimsIdentity)

Gets the scopes list stored in the claims identity.

public static ImmutableArray<string> GetScopes(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

ImmutableArray<string>

The scopes list or an empty set if the claim cannot be found.

GetScopes(ClaimsPrincipal)

Gets the scopes list stored in the claims principal.

public static ImmutableArray<string> GetScopes(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

ImmutableArray<string>

The scopes list or an empty set if the claim cannot be found.

GetStateTokenLifetime(ClaimsIdentity)

Gets the state token lifetime associated with the claims identity.

public static TimeSpan? GetStateTokenLifetime(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

TimeSpan?

The state token lifetime or null if the claim cannot be found.

GetStateTokenLifetime(ClaimsPrincipal)

Gets the state token lifetime associated with the claims principal.

public static TimeSpan? GetStateTokenLifetime(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

TimeSpan?

The state token lifetime or null if the claim cannot be found.

GetTokenId(ClaimsIdentity)

Gets the internal token identifier associated with the claims identity.

public static string? GetTokenId(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

string

The unique identifier or null if the claim cannot be found.

GetTokenId(ClaimsPrincipal)

Gets the internal token identifier associated with the claims principal.

public static string? GetTokenId(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

string

The unique identifier or null if the claim cannot be found.

GetTokenType(ClaimsIdentity)

Gets the token type associated with the claims identity.

public static string? GetTokenType(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

string

The token type or null if the claim cannot be found.

GetTokenType(ClaimsPrincipal)

Gets the token type associated with the claims principal.

public static string? GetTokenType(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

string

The token type or null if the claim cannot be found.

GetUserCodeLifetime(ClaimsIdentity)

Gets the user code lifetime associated with the claims identity.

public static TimeSpan? GetUserCodeLifetime(this ClaimsIdentity identity)

Parameters

identity ClaimsIdentity

The claims identity.

Returns

TimeSpan?

The user code lifetime or null if the claim cannot be found.

GetUserCodeLifetime(ClaimsPrincipal)

Gets the user code lifetime associated with the claims principal.

public static TimeSpan? GetUserCodeLifetime(this ClaimsPrincipal principal)

Parameters

principal ClaimsPrincipal

The claims principal.

Returns

TimeSpan?

The user code lifetime or null if the claim cannot be found.

HasAcrValue(OpenIddictRequest, string)

Determines whether the requested authentication context class values contain the specified item.

public static bool HasAcrValue(this OpenIddictRequest request, string value)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

value string

The component to look for in the parameter.

Returns

bool

HasAudience(ClaimsIdentity, string)

Determines whether the claims identity contains the given audience.

public static bool HasAudience(this ClaimsIdentity identity, string audience)

Parameters

identity ClaimsIdentity

The claims identity.

audience string

The audience.

Returns

bool

true if the identity contains the given audience.

HasAudience(ClaimsPrincipal, string)

Determines whether the claims principal contains the given audience.

public static bool HasAudience(this ClaimsPrincipal principal, string audience)

Parameters

principal ClaimsPrincipal

The claims principal.

audience string

The audience.

Returns

bool

true if the principal contains the given audience.

HasClaim(ClaimsIdentity, string)

Determines whether the claims identity contains at least one claim of the specified type.

public static bool HasClaim(this ClaimsIdentity identity, string type)

Parameters

identity ClaimsIdentity

The claims identity.

type string

The claim type.

Returns

bool

true if the identity contains at least one claim of the specified type.

HasClaim(ClaimsPrincipal, string)

Determines whether the claims principal contains at least one claim of the specified type.

public static bool HasClaim(this ClaimsPrincipal principal, string type)

Parameters

principal ClaimsPrincipal

The claims principal.

type string

The claim type.

Returns

bool

true if the principal contains at least one claim of the specified type.

HasDestination(Claim, string)

Determines whether the given claim contains the required destination.

public static bool HasDestination(this Claim claim, string destination)

Parameters

claim Claim

The Claim instance.

destination string

The required destination.

Returns

bool

HasPresenter(ClaimsIdentity, string)

Determines whether the claims identity contains the given presenter.

public static bool HasPresenter(this ClaimsIdentity identity, string presenter)

Parameters

identity ClaimsIdentity

The claims identity.

presenter string

The presenter.

Returns

bool

true if the identity contains the given presenter.

HasPresenter(ClaimsPrincipal, string)

Determines whether the claims principal contains the given presenter.

public static bool HasPresenter(this ClaimsPrincipal principal, string presenter)

Parameters

principal ClaimsPrincipal

The claims principal.

presenter string

The presenter.

Returns

bool

true if the principal contains the given presenter.

HasPrompt(OpenIddictRequest, string)

Determines whether the requested prompt contains the specified value.

public static bool HasPrompt(this OpenIddictRequest request, string prompt)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

prompt string

The component to look for in the parameter.

Returns

bool

HasResource(ClaimsIdentity, string)

Determines whether the claims identity contains the given resource.

public static bool HasResource(this ClaimsIdentity identity, string resource)

Parameters

identity ClaimsIdentity

The claims identity.

resource string

The resource.

Returns

bool

true if the identity contains the given resource.

HasResource(ClaimsPrincipal, string)

Determines whether the claims principal contains the given resource.

public static bool HasResource(this ClaimsPrincipal principal, string resource)

Parameters

principal ClaimsPrincipal

The claims principal.

resource string

The resource.

Returns

bool

true if the principal contains the given resource.

HasResponseType(OpenIddictRequest, string)

Determines whether the requested response type contains the specified value.

public static bool HasResponseType(this OpenIddictRequest request, string type)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

type string

The component to look for in the parameter.

Returns

bool

HasScope(OpenIddictRequest, string)

Determines whether the requested scope contains the specified value.

public static bool HasScope(this OpenIddictRequest request, string scope)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

scope string

The component to look for in the parameter.

Returns

bool

HasScope(ClaimsIdentity, string)

Determines whether the claims identity contains the given scope.

public static bool HasScope(this ClaimsIdentity identity, string scope)

Parameters

identity ClaimsIdentity

The claims identity.

scope string

The scope.

Returns

bool

true if the identity contains the given scope.

HasScope(ClaimsPrincipal, string)

Determines whether the claims principal contains the given scope.

public static bool HasScope(this ClaimsPrincipal principal, string scope)

Parameters

principal ClaimsPrincipal

The claims principal.

scope string

The scope.

Returns

bool

true if the principal contains the given scope.

HasTokenType(ClaimsIdentity, string)

Determines whether the token type associated with the claims identity matches the specified type.

public static bool HasTokenType(this ClaimsIdentity identity, string type)

Parameters

identity ClaimsIdentity

The claims identity.

type string

The token type.

Returns

bool

true if the token type matches the specified type.

HasTokenType(ClaimsPrincipal, string)

Determines whether the token type associated with the claims principal matches the specified type.

public static bool HasTokenType(this ClaimsPrincipal principal, string type)

Parameters

principal ClaimsPrincipal

The claims principal.

type string

The token type.

Returns

bool

true if the token type matches the specified type.

IsAuthorizationCodeFlow(OpenIddictRequest)

Determines whether the "response_type" parameter corresponds to the authorization code flow. See http://tools.ietf.org/html/rfc6749#section-4.1.1 for more information.

public static bool IsAuthorizationCodeFlow(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

bool

true if the request is a code flow request, false otherwise.

IsAuthorizationCodeGrantType(OpenIddictRequest)

Determines whether the "grant_type" parameter corresponds to the authorization code grant. See http://tools.ietf.org/html/rfc6749#section-4.1.3 for more information.

public static bool IsAuthorizationCodeGrantType(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

bool

true if the request is a code grant request, false otherwise.

IsClientCredentialsGrantType(OpenIddictRequest)

Determines whether the "grant_type" parameter corresponds to the client credentials grant. See http://tools.ietf.org/html/rfc6749#section-4.4.2 for more information.

public static bool IsClientCredentialsGrantType(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

bool

true if the request is a client credentials grant request, false otherwise.

IsDeviceCodeGrantType(OpenIddictRequest)

Determines whether the "grant_type" parameter corresponds to the device code grant. See https://tools.ietf.org/html/rfc8628 for more information.

public static bool IsDeviceCodeGrantType(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

bool

true if the request is a device code grant request, false otherwise.

IsFormPostResponseMode(OpenIddictRequest)

Determines whether the "response_mode" parameter corresponds to the form post response mode. See http://openid.net/specs/oauth-v2-form-post-response-mode-1_0.html for more information.

public static bool IsFormPostResponseMode(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

bool

true if the request specified the form post response mode or if it's the default value for the requested flow, false otherwise.

IsFragmentResponseMode(OpenIddictRequest)

Determines whether the "response_mode" parameter corresponds to the fragment response mode. See http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html for more information.

public static bool IsFragmentResponseMode(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

bool

true if the request specified the fragment response mode or if it's the default value for the requested flow, false otherwise.

IsHybridFlow(OpenIddictRequest)

Determines whether the "response_type" parameter corresponds to the hybrid flow. See http://tools.ietf.org/html/rfc6749#section-4.2.1 and http://openid.net/specs/openid-connect-core-1_0.html for more information.

public static bool IsHybridFlow(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

bool

true if the request is an hybrid flow request, false otherwise.

IsImplicitFlow(OpenIddictRequest)

Determines whether the "response_type" parameter corresponds to the implicit flow. See http://tools.ietf.org/html/rfc6749#section-4.2.1 and http://openid.net/specs/openid-connect-core-1_0.html for more information

public static bool IsImplicitFlow(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

bool

true if the request is an implicit flow request, false otherwise.

IsNoneFlow(OpenIddictRequest)

Determines whether the "response_type" parameter corresponds to the "none" response type. See http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html#none for more information.

public static bool IsNoneFlow(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

bool

true if the request is a response_type=none request, false otherwise.

IsPasswordGrantType(OpenIddictRequest)

Determines whether the "grant_type" parameter corresponds to the password grant. See http://tools.ietf.org/html/rfc6749#section-4.3.2 for more information.

public static bool IsPasswordGrantType(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

bool

true if the request is a password grant request, false otherwise.

IsQueryResponseMode(OpenIddictRequest)

Determines whether the "response_mode" parameter corresponds to the query response mode. See http://openid.net/specs/oauth-v2-multiple-response-types-1_0.html for more information.

public static bool IsQueryResponseMode(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

bool

true if the request specified the query response mode or if it's the default value for the requested flow, false otherwise.

IsRefreshTokenGrantType(OpenIddictRequest)

Determines whether the "grant_type" parameter corresponds to the refresh token grant. See http://tools.ietf.org/html/rfc6749#section-6 for more information.

public static bool IsRefreshTokenGrantType(this OpenIddictRequest request)

Parameters

request OpenIddictRequest

The OpenIddictRequest instance.

Returns

bool

true if the request is a refresh token grant request, false otherwise.

RemoveClaims(ClaimsIdentity, string)

Removes all the claims corresponding to the given type.

public static ClaimsIdentity RemoveClaims(this ClaimsIdentity identity, string type)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claims.

Returns

ClaimsIdentity

The claims identity.

RemoveClaims(ClaimsPrincipal, string)

Removes all the claims corresponding to the given type.

public static ClaimsPrincipal RemoveClaims(this ClaimsPrincipal principal, string type)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claims.

Returns

ClaimsPrincipal

The claims identity.

SetAccessTokenLifetime(ClaimsIdentity, TimeSpan?)

Sets the access token lifetime associated with the claims identity.

public static ClaimsIdentity SetAccessTokenLifetime(this ClaimsIdentity identity, TimeSpan? lifetime)

Parameters

identity ClaimsIdentity

The claims identity.

lifetime TimeSpan?

The access token lifetime to store.

Returns

ClaimsIdentity

The claims identity.

SetAccessTokenLifetime(ClaimsPrincipal, TimeSpan?)

Sets the access token lifetime associated with the claims principal.

public static ClaimsPrincipal SetAccessTokenLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)

Parameters

principal ClaimsPrincipal

The claims principal.

lifetime TimeSpan?

The access token lifetime to store.

Returns

ClaimsPrincipal

The claims principal.

SetAudiences(ClaimsIdentity, IEnumerable<string>?)

Sets the audiences list in the claims identity. Note: this method automatically excludes duplicate audiences.

public static ClaimsIdentity SetAudiences(this ClaimsIdentity identity, IEnumerable<string>? audiences)

Parameters

identity ClaimsIdentity

The claims identity.

audiences IEnumerable<string>

The audiences to store.

Returns

ClaimsIdentity

The claims identity.

SetAudiences(ClaimsIdentity, ImmutableArray<string>)

Sets the audiences list in the claims identity. Note: this method automatically excludes duplicate audiences.

public static ClaimsIdentity SetAudiences(this ClaimsIdentity identity, ImmutableArray<string> audiences)

Parameters

identity ClaimsIdentity

The claims identity.

audiences ImmutableArray<string>

The audiences to store.

Returns

ClaimsIdentity

The claims identity.

SetAudiences(ClaimsIdentity, params string[]?)

Sets the audiences list in the claims identity. Note: this method automatically excludes duplicate audiences.

public static ClaimsIdentity SetAudiences(this ClaimsIdentity identity, params string[]? audiences)

Parameters

identity ClaimsIdentity

The claims identity.

audiences string[]

The audiences to store.

Returns

ClaimsIdentity

The claims identity.

SetAudiences(ClaimsPrincipal, IEnumerable<string>?)

Sets the audiences list in the claims principal. Note: this method automatically excludes duplicate audiences.

public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, IEnumerable<string>? audiences)

Parameters

principal ClaimsPrincipal

The claims principal.

audiences IEnumerable<string>

The audiences to store.

Returns

ClaimsPrincipal

The claims principal.

SetAudiences(ClaimsPrincipal, ImmutableArray<string>)

Sets the audiences list in the claims principal. Note: this method automatically excludes duplicate audiences.

public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, ImmutableArray<string> audiences)

Parameters

principal ClaimsPrincipal

The claims principal.

audiences ImmutableArray<string>

The audiences to store.

Returns

ClaimsPrincipal

The claims principal.

SetAudiences(ClaimsPrincipal, params string[]?)

Sets the audiences list in the claims principal. Note: this method automatically excludes duplicate audiences.

public static ClaimsPrincipal SetAudiences(this ClaimsPrincipal principal, params string[]? audiences)

Parameters

principal ClaimsPrincipal

The claims principal.

audiences string[]

The audiences to store.

Returns

ClaimsPrincipal

The claims principal.

SetAuthorizationCodeLifetime(ClaimsIdentity, TimeSpan?)

Sets the authorization code lifetime associated with the claims identity.

public static ClaimsIdentity SetAuthorizationCodeLifetime(this ClaimsIdentity identity, TimeSpan? lifetime)

Parameters

identity ClaimsIdentity

The claims identity.

lifetime TimeSpan?

The authorization code lifetime to store.

Returns

ClaimsIdentity

The claims identity.

SetAuthorizationCodeLifetime(ClaimsPrincipal, TimeSpan?)

Sets the authorization code lifetime associated with the claims principal.

public static ClaimsPrincipal SetAuthorizationCodeLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)

Parameters

principal ClaimsPrincipal

The claims principal.

lifetime TimeSpan?

The authorization code lifetime to store.

Returns

ClaimsPrincipal

The claims principal.

SetAuthorizationId(ClaimsIdentity, string?)

Sets the internal authorization identifier associated with the claims identity.

public static ClaimsIdentity SetAuthorizationId(this ClaimsIdentity identity, string? identifier)

Parameters

identity ClaimsIdentity

The claims identity.

identifier string

The unique identifier to store.

Returns

ClaimsIdentity

The claims identity.

SetAuthorizationId(ClaimsPrincipal, string?)

Sets the internal authorization identifier associated with the claims principal.

public static ClaimsPrincipal SetAuthorizationId(this ClaimsPrincipal principal, string? identifier)

Parameters

principal ClaimsPrincipal

The claims principal.

identifier string

The unique identifier to store.

Returns

ClaimsPrincipal

The claims principal.

SetClaim(ClaimsIdentity, string, IDictionary<string, string?>?)

Sets the claim value corresponding to the given type.

public static ClaimsIdentity SetClaim(this ClaimsIdentity identity, string type, IDictionary<string, string?>? value)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value IDictionary<string, string>

The value associated with the claim.

Returns

ClaimsIdentity

The claims identity.

SetClaim(ClaimsIdentity, string, IDictionary<string, string?>?, string)

Sets the claim value corresponding to the given type.

public static ClaimsIdentity SetClaim(this ClaimsIdentity identity, string type, IDictionary<string, string?>? value, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value IDictionary<string, string>

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsIdentity

The claims identity.

SetClaim(ClaimsIdentity, string, bool?)

Sets the claim value corresponding to the given type.

public static ClaimsIdentity SetClaim(this ClaimsIdentity identity, string type, bool? value)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value bool?

The value associated with the claim.

Returns

ClaimsIdentity

The claims identity.

SetClaim(ClaimsIdentity, string, bool?, string)

Sets the claim value corresponding to the given type.

public static ClaimsIdentity SetClaim(this ClaimsIdentity identity, string type, bool? value, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value bool?

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsIdentity

The claims identity.

SetClaim(ClaimsIdentity, string, long?)

Sets the claim value corresponding to the given type.

public static ClaimsIdentity SetClaim(this ClaimsIdentity identity, string type, long? value)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value long?

The value associated with the claim.

Returns

ClaimsIdentity

The claims identity.

SetClaim(ClaimsIdentity, string, long?, string)

Sets the claim value corresponding to the given type.

public static ClaimsIdentity SetClaim(this ClaimsIdentity identity, string type, long? value, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value long?

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsIdentity

The claims identity.

SetClaim(ClaimsIdentity, string, string?)

Sets the claim value corresponding to the given type.

public static ClaimsIdentity SetClaim(this ClaimsIdentity identity, string type, string? value)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value string

The value associated with the claim.

Returns

ClaimsIdentity

The claims identity.

SetClaim(ClaimsIdentity, string, string?, string)

Sets the claim value corresponding to the given type.

public static ClaimsIdentity SetClaim(this ClaimsIdentity identity, string type, string? value, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value string

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsIdentity

The claims identity.

SetClaim(ClaimsIdentity, string, JsonElement)

Sets the claim value corresponding to the given type.

public static ClaimsIdentity SetClaim(this ClaimsIdentity identity, string type, JsonElement value)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value JsonElement

The value associated with the claim.

Returns

ClaimsIdentity

The claims identity.

SetClaim(ClaimsIdentity, string, JsonElement, string)

Sets the claim value corresponding to the given type.

public static ClaimsIdentity SetClaim(this ClaimsIdentity identity, string type, JsonElement value, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claim.

value JsonElement

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsIdentity

The claims identity.

SetClaim(ClaimsPrincipal, string, IDictionary<string, string?>?)

Sets the claim value corresponding to the given type.

public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, IDictionary<string, string?>? value)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value IDictionary<string, string>

The value associated with the claim.

Returns

ClaimsPrincipal

The claims identity.

SetClaim(ClaimsPrincipal, string, IDictionary<string, string?>?, string)

Sets the claim value corresponding to the given type.

public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, IDictionary<string, string?>? value, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value IDictionary<string, string>

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsPrincipal

The claims identity.

SetClaim(ClaimsPrincipal, string, bool?)

Sets the claim value corresponding to the given type.

public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, bool? value)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value bool?

The value associated with the claim.

Returns

ClaimsPrincipal

The claims identity.

SetClaim(ClaimsPrincipal, string, bool?, string)

Sets the claim value corresponding to the given type.

public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, bool? value, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value bool?

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsPrincipal

The claims identity.

SetClaim(ClaimsPrincipal, string, long?)

Sets the claim value corresponding to the given type.

public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, long? value)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value long?

The value associated with the claim.

Returns

ClaimsPrincipal

The claims identity.

SetClaim(ClaimsPrincipal, string, long?, string)

Sets the claim value corresponding to the given type.

public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, long? value, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value long?

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsPrincipal

The claims identity.

SetClaim(ClaimsPrincipal, string, string?)

Sets the claim value corresponding to the given type.

public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, string? value)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value string

The value associated with the claim.

Returns

ClaimsPrincipal

The claims identity.

SetClaim(ClaimsPrincipal, string, string?, string)

Sets the claim value corresponding to the given type.

public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, string? value, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value string

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsPrincipal

The claims identity.

SetClaim(ClaimsPrincipal, string, JsonElement)

Sets the claim value corresponding to the given type.

public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, JsonElement value)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value JsonElement

The value associated with the claim.

Returns

ClaimsPrincipal

The claims identity.

SetClaim(ClaimsPrincipal, string, JsonElement, string)

Sets the claim value corresponding to the given type.

public static ClaimsPrincipal SetClaim(this ClaimsPrincipal principal, string type, JsonElement value, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claim.

value JsonElement

The value associated with the claim.

issuer string

The issuer associated with the claim.

Returns

ClaimsPrincipal

The claims identity.

SetClaims(ClaimsIdentity, string, ImmutableArray<string>)

Sets the claim values corresponding to the given type.

public static ClaimsIdentity SetClaims(this ClaimsIdentity identity, string type, ImmutableArray<string> values)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claims.

values ImmutableArray<string>

The values associated with the claims.

Returns

ClaimsIdentity

The claims identity.

SetClaims(ClaimsIdentity, string, ImmutableArray<string>, string)

Sets the claim values corresponding to the given type.

public static ClaimsIdentity SetClaims(this ClaimsIdentity identity, string type, ImmutableArray<string> values, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claims.

values ImmutableArray<string>

The values associated with the claims.

issuer string

The issuer associated with the claims.

Returns

ClaimsIdentity

The claims identity.

SetClaims(ClaimsIdentity, string, JsonElement)

Sets the claim values corresponding to the given type.

public static ClaimsIdentity SetClaims(this ClaimsIdentity identity, string type, JsonElement value)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claims.

value JsonElement

The JSON array from which claim values are extracted.

Returns

ClaimsIdentity

The claims identity.

SetClaims(ClaimsIdentity, string, JsonElement, string)

Sets the claim values corresponding to the given type.

public static ClaimsIdentity SetClaims(this ClaimsIdentity identity, string type, JsonElement value, string issuer)

Parameters

identity ClaimsIdentity

The identity.

type string

The type associated with the claims.

value JsonElement

The JSON array from which claim values are extracted.

issuer string

The issuer associated with the claims.

Returns

ClaimsIdentity

The claims identity.

SetClaims(ClaimsPrincipal, string, ImmutableArray<string>)

Sets the claim values corresponding to the given type.

public static ClaimsPrincipal SetClaims(this ClaimsPrincipal principal, string type, ImmutableArray<string> values)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claims.

values ImmutableArray<string>

The values associated with the claims.

Returns

ClaimsPrincipal

The claims identity.

SetClaims(ClaimsPrincipal, string, ImmutableArray<string>, string)

Sets the claim values corresponding to the given type.

public static ClaimsPrincipal SetClaims(this ClaimsPrincipal principal, string type, ImmutableArray<string> values, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claims.

values ImmutableArray<string>

The values associated with the claims.

issuer string

The issuer associated with the claims.

Returns

ClaimsPrincipal

The claims identity.

SetClaims(ClaimsPrincipal, string, JsonElement)

Sets the claim values corresponding to the given type.

public static ClaimsPrincipal SetClaims(this ClaimsPrincipal principal, string type, JsonElement value)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claims.

value JsonElement

The JSON array from which claim values are extracted.

Returns

ClaimsPrincipal

The claims identity.

SetClaims(ClaimsPrincipal, string, JsonElement, string)

Sets the claim value corresponding to the given type.

public static ClaimsPrincipal SetClaims(this ClaimsPrincipal principal, string type, JsonElement value, string issuer)

Parameters

principal ClaimsPrincipal

The principal.

type string

The type associated with the claims.

value JsonElement

The JSON array from which claim values are extracted.

issuer string

The issuer associated with the claims.

Returns

ClaimsPrincipal

The claims identity.

SetCreationDate(ClaimsIdentity, DateTimeOffset?)

Sets the creation date in the claims identity.

public static ClaimsIdentity SetCreationDate(this ClaimsIdentity identity, DateTimeOffset? date)

Parameters

identity ClaimsIdentity

The claims identity.

date DateTimeOffset?

The creation date

Returns

ClaimsIdentity

The claims identity.

SetCreationDate(ClaimsPrincipal, DateTimeOffset?)

Sets the creation date in the claims principal.

public static ClaimsPrincipal SetCreationDate(this ClaimsPrincipal principal, DateTimeOffset? date)

Parameters

principal ClaimsPrincipal

The claims principal.

date DateTimeOffset?

The creation date

Returns

ClaimsPrincipal

The claims principal.

SetDestinations(Claim, IEnumerable<string>?)

Adds specific destinations to a claim.

public static Claim SetDestinations(this Claim claim, IEnumerable<string>? destinations)

Parameters

claim Claim

The Claim instance.

destinations IEnumerable<string>

The destinations.

Returns

Claim

SetDestinations(Claim, ImmutableArray<string>)

Adds specific destinations to a claim.

public static Claim SetDestinations(this Claim claim, ImmutableArray<string> destinations)

Parameters

claim Claim

The Claim instance.

destinations ImmutableArray<string>

The destinations.

Returns

Claim

SetDestinations(Claim, params string[]?)

Adds specific destinations to a claim.

public static Claim SetDestinations(this Claim claim, params string[]? destinations)

Parameters

claim Claim

The Claim instance.

destinations string[]

The destinations.

Returns

Claim

SetDestinations(ClaimsIdentity, ImmutableDictionary<string, string[]>)

Sets the destinations associated with all the claims of the given identity.

public static ClaimsIdentity SetDestinations(this ClaimsIdentity identity, ImmutableDictionary<string, string[]> destinations)

Parameters

identity ClaimsIdentity

The identity.

destinations ImmutableDictionary<string, string[]>

The destinations, as a flattened dictionary.

Returns

ClaimsIdentity

The identity.

SetDestinations(ClaimsIdentity, Func<Claim, IEnumerable<string>>)

Sets the destinations associated with all the claims of the given identity.

public static ClaimsIdentity SetDestinations(this ClaimsIdentity identity, Func<Claim, IEnumerable<string>> selector)

Parameters

identity ClaimsIdentity

The identity.

selector Func<Claim, IEnumerable<string>>

The destinations selector delegate.

Returns

ClaimsIdentity

The identity.

SetDestinations(ClaimsPrincipal, ImmutableDictionary<string, string[]>)

Sets the destinations associated with all the claims of the given principal.

public static ClaimsPrincipal SetDestinations(this ClaimsPrincipal principal, ImmutableDictionary<string, string[]> destinations)

Parameters

principal ClaimsPrincipal

The principal.

destinations ImmutableDictionary<string, string[]>

The destinations, as a flattened dictionary.

Returns

ClaimsPrincipal

The principal.

SetDestinations(ClaimsPrincipal, Func<Claim, IEnumerable<string>>)

Sets the destinations associated with all the claims of the given principal.

public static ClaimsPrincipal SetDestinations(this ClaimsPrincipal principal, Func<Claim, IEnumerable<string>> selector)

Parameters

principal ClaimsPrincipal

The principal.

selector Func<Claim, IEnumerable<string>>

The destinations selector delegate.

Returns

ClaimsPrincipal

The principal.

SetDeviceCodeLifetime(ClaimsIdentity, TimeSpan?)

Sets the device code lifetime associated with the claims identity.

public static ClaimsIdentity SetDeviceCodeLifetime(this ClaimsIdentity identity, TimeSpan? lifetime)

Parameters

identity ClaimsIdentity

The claims identity.

lifetime TimeSpan?

The device code lifetime to store.

Returns

ClaimsIdentity

The claims identity.

SetDeviceCodeLifetime(ClaimsPrincipal, TimeSpan?)

Sets the device code lifetime associated with the claims principal.

public static ClaimsPrincipal SetDeviceCodeLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)

Parameters

principal ClaimsPrincipal

The claims principal.

lifetime TimeSpan?

The device code lifetime to store.

Returns

ClaimsPrincipal

The claims principal.

SetExpirationDate(ClaimsIdentity, DateTimeOffset?)

Sets the expiration date in the claims identity.

public static ClaimsIdentity SetExpirationDate(this ClaimsIdentity identity, DateTimeOffset? date)

Parameters

identity ClaimsIdentity

The claims identity.

date DateTimeOffset?

The expiration date

Returns

ClaimsIdentity

The claims identity.

SetExpirationDate(ClaimsPrincipal, DateTimeOffset?)

Sets the expiration date in the claims principal.

public static ClaimsPrincipal SetExpirationDate(this ClaimsPrincipal principal, DateTimeOffset? date)

Parameters

principal ClaimsPrincipal

The claims principal.

date DateTimeOffset?

The expiration date

Returns

ClaimsPrincipal

The claims principal.

SetIdentityTokenLifetime(ClaimsIdentity, TimeSpan?)

Sets the identity token lifetime associated with the claims identity.

public static ClaimsIdentity SetIdentityTokenLifetime(this ClaimsIdentity identity, TimeSpan? lifetime)

Parameters

identity ClaimsIdentity

The claims identity.

lifetime TimeSpan?

The identity token lifetime to store.

Returns

ClaimsIdentity

The claims identity.

SetIdentityTokenLifetime(ClaimsPrincipal, TimeSpan?)

Sets the identity token lifetime associated with the claims principal.

public static ClaimsPrincipal SetIdentityTokenLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)

Parameters

principal ClaimsPrincipal

The claims principal.

lifetime TimeSpan?

The identity token lifetime to store.

Returns

ClaimsPrincipal

The claims principal.

SetPresenters(ClaimsIdentity, IEnumerable<string>?)

Sets the presenters list in the claims identity. Note: this method automatically excludes duplicate presenters.

public static ClaimsIdentity SetPresenters(this ClaimsIdentity identity, IEnumerable<string>? presenters)

Parameters

identity ClaimsIdentity

The claims identity.

presenters IEnumerable<string>

The presenters to store.

Returns

ClaimsIdentity

The claims identity.

SetPresenters(ClaimsIdentity, ImmutableArray<string>)

Sets the presenters list in the claims identity. Note: this method automatically excludes duplicate presenters.

public static ClaimsIdentity SetPresenters(this ClaimsIdentity identity, ImmutableArray<string> presenters)

Parameters

identity ClaimsIdentity

The claims identity.

presenters ImmutableArray<string>

The presenters to store.

Returns

ClaimsIdentity

The claims identity.

SetPresenters(ClaimsIdentity, params string[]?)

Sets the presenters list in the claims identity. Note: this method automatically excludes duplicate presenters.

public static ClaimsIdentity SetPresenters(this ClaimsIdentity identity, params string[]? presenters)

Parameters

identity ClaimsIdentity

The claims identity.

presenters string[]

The presenters to store.

Returns

ClaimsIdentity

The claims identity.

SetPresenters(ClaimsPrincipal, IEnumerable<string>?)

Sets the presenters list in the claims principal. Note: this method automatically excludes duplicate presenters.

public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, IEnumerable<string>? presenters)

Parameters

principal ClaimsPrincipal

The claims principal.

presenters IEnumerable<string>

The presenters to store.

Returns

ClaimsPrincipal

The claims principal.

SetPresenters(ClaimsPrincipal, ImmutableArray<string>)

Sets the presenters list in the claims principal. Note: this method automatically excludes duplicate presenters.

public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, ImmutableArray<string> presenters)

Parameters

principal ClaimsPrincipal

The claims principal.

presenters ImmutableArray<string>

The presenters to store.

Returns

ClaimsPrincipal

The claims principal.

SetPresenters(ClaimsPrincipal, params string[]?)

Sets the presenters list in the claims principal. Note: this method automatically excludes duplicate presenters.

public static ClaimsPrincipal SetPresenters(this ClaimsPrincipal principal, params string[]? presenters)

Parameters

principal ClaimsPrincipal

The claims principal.

presenters string[]

The presenters to store.

Returns

ClaimsPrincipal

The claims principal.

SetRefreshTokenLifetime(ClaimsIdentity, TimeSpan?)

Sets the refresh token lifetime associated with the claims identity.

public static ClaimsIdentity SetRefreshTokenLifetime(this ClaimsIdentity identity, TimeSpan? lifetime)

Parameters

identity ClaimsIdentity

The claims identity.

lifetime TimeSpan?

The refresh token lifetime to store.

Returns

ClaimsIdentity

The claims identity.

SetRefreshTokenLifetime(ClaimsPrincipal, TimeSpan?)

Sets the refresh token lifetime associated with the claims principal.

public static ClaimsPrincipal SetRefreshTokenLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)

Parameters

principal ClaimsPrincipal

The claims principal.

lifetime TimeSpan?

The refresh token lifetime to store.

Returns

ClaimsPrincipal

The claims principal.

SetResources(ClaimsIdentity, IEnumerable<string>?)

Sets the resources list in the claims identity. Note: this method automatically excludes duplicate resources.

public static ClaimsIdentity SetResources(this ClaimsIdentity identity, IEnumerable<string>? resources)

Parameters

identity ClaimsIdentity

The claims identity.

resources IEnumerable<string>

The resources to store.

Returns

ClaimsIdentity

The claims identity.

SetResources(ClaimsIdentity, ImmutableArray<string>)

Sets the resources list in the claims identity. Note: this method automatically excludes duplicate resources.

public static ClaimsIdentity SetResources(this ClaimsIdentity identity, ImmutableArray<string> resources)

Parameters

identity ClaimsIdentity

The claims identity.

resources ImmutableArray<string>

The resources to store.

Returns

ClaimsIdentity

The claims identity.

SetResources(ClaimsIdentity, params string[]?)

Sets the resources list in the claims identity. Note: this method automatically excludes duplicate resources.

public static ClaimsIdentity SetResources(this ClaimsIdentity identity, params string[]? resources)

Parameters

identity ClaimsIdentity

The claims identity.

resources string[]

The resources to store.

Returns

ClaimsIdentity

The claims identity.

SetResources(ClaimsPrincipal, IEnumerable<string>?)

Sets the resources list in the claims principal. Note: this method automatically excludes duplicate resources.

public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, IEnumerable<string>? resources)

Parameters

principal ClaimsPrincipal

The claims principal.

resources IEnumerable<string>

The resources to store.

Returns

ClaimsPrincipal

The claims principal.

SetResources(ClaimsPrincipal, ImmutableArray<string>)

Sets the resources list in the claims principal. Note: this method automatically excludes duplicate resources.

public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, ImmutableArray<string> resources)

Parameters

principal ClaimsPrincipal

The claims principal.

resources ImmutableArray<string>

The resources to store.

Returns

ClaimsPrincipal

The claims principal.

SetResources(ClaimsPrincipal, params string[]?)

Sets the resources list in the claims principal. Note: this method automatically excludes duplicate resources.

public static ClaimsPrincipal SetResources(this ClaimsPrincipal principal, params string[]? resources)

Parameters

principal ClaimsPrincipal

The claims principal.

resources string[]

The resources to store.

Returns

ClaimsPrincipal

The claims principal.

SetScopes(ClaimsIdentity, IEnumerable<string>?)

Sets the scopes list in the claims identity. Note: this method automatically excludes duplicate scopes.

public static ClaimsIdentity SetScopes(this ClaimsIdentity identity, IEnumerable<string>? scopes)

Parameters

identity ClaimsIdentity

The claims identity.

scopes IEnumerable<string>

The scopes to store.

Returns

ClaimsIdentity

The claims identity.

SetScopes(ClaimsIdentity, ImmutableArray<string>)

Sets the scopes list in the claims identity. Note: this method automatically excludes duplicate scopes.

public static ClaimsIdentity SetScopes(this ClaimsIdentity identity, ImmutableArray<string> scopes)

Parameters

identity ClaimsIdentity

The claims identity.

scopes ImmutableArray<string>

The scopes to store.

Returns

ClaimsIdentity

The claims identity.

SetScopes(ClaimsIdentity, params string[]?)

Sets the scopes list in the claims identity. Note: this method automatically excludes duplicate scopes.

public static ClaimsIdentity SetScopes(this ClaimsIdentity identity, params string[]? scopes)

Parameters

identity ClaimsIdentity

The claims identity.

scopes string[]

The scopes to store.

Returns

ClaimsIdentity

The claims identity.

SetScopes(ClaimsPrincipal, IEnumerable<string>?)

Sets the scopes list in the claims principal. Note: this method automatically excludes duplicate scopes.

public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, IEnumerable<string>? scopes)

Parameters

principal ClaimsPrincipal

The claims principal.

scopes IEnumerable<string>

The scopes to store.

Returns

ClaimsPrincipal

The claims principal.

SetScopes(ClaimsPrincipal, ImmutableArray<string>)

Sets the scopes list in the claims principal. Note: this method automatically excludes duplicate scopes.

public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, ImmutableArray<string> scopes)

Parameters

principal ClaimsPrincipal

The claims principal.

scopes ImmutableArray<string>

The scopes to store.

Returns

ClaimsPrincipal

The claims principal.

SetScopes(ClaimsPrincipal, params string[]?)

Sets the scopes list in the claims principal. Note: this method automatically excludes duplicate scopes.

public static ClaimsPrincipal SetScopes(this ClaimsPrincipal principal, params string[]? scopes)

Parameters

principal ClaimsPrincipal

The claims principal.

scopes string[]

The scopes to store.

Returns

ClaimsPrincipal

The claims principal.

SetStateTokenLifetime(ClaimsIdentity, TimeSpan?)

Sets the state token lifetime associated with the claims identity.

public static ClaimsIdentity SetStateTokenLifetime(this ClaimsIdentity identity, TimeSpan? lifetime)

Parameters

identity ClaimsIdentity

The claims identity.

lifetime TimeSpan?

The state token lifetime to store.

Returns

ClaimsIdentity

The claims identity.

SetStateTokenLifetime(ClaimsPrincipal, TimeSpan?)

Sets the state token lifetime associated with the claims principal.

public static ClaimsPrincipal SetStateTokenLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)

Parameters

principal ClaimsPrincipal

The claims principal.

lifetime TimeSpan?

The state token lifetime to store.

Returns

ClaimsPrincipal

The claims principal.

SetTokenId(ClaimsIdentity, string?)

Sets the internal token identifier associated with the claims identity.

public static ClaimsIdentity SetTokenId(this ClaimsIdentity identity, string? identifier)

Parameters

identity ClaimsIdentity

The claims identity.

identifier string

The unique identifier to store.

Returns

ClaimsIdentity

The claims identity.

SetTokenId(ClaimsPrincipal, string?)

Sets the internal token identifier associated with the claims principal.

public static ClaimsPrincipal SetTokenId(this ClaimsPrincipal principal, string? identifier)

Parameters

principal ClaimsPrincipal

The claims principal.

identifier string

The unique identifier to store.

Returns

ClaimsPrincipal

The claims principal.

SetTokenType(ClaimsIdentity, string?)

Sets the token type associated with the claims identity.

public static ClaimsIdentity SetTokenType(this ClaimsIdentity identity, string? type)

Parameters

identity ClaimsIdentity

The claims identity.

type string

The token type to store.

Returns

ClaimsIdentity

The claims identity.

SetTokenType(ClaimsPrincipal, string?)

Sets the token type associated with the claims principal.

public static ClaimsPrincipal SetTokenType(this ClaimsPrincipal principal, string? type)

Parameters

principal ClaimsPrincipal

The claims principal.

type string

The token type to store.

Returns

ClaimsPrincipal

The claims principal.

SetUserCodeLifetime(ClaimsIdentity, TimeSpan?)

Sets the user code lifetime associated with the claims identity.

public static ClaimsIdentity SetUserCodeLifetime(this ClaimsIdentity identity, TimeSpan? lifetime)

Parameters

identity ClaimsIdentity

The claims identity.

lifetime TimeSpan?

The user code lifetime to store.

Returns

ClaimsIdentity

The claims identity.

SetUserCodeLifetime(ClaimsPrincipal, TimeSpan?)

Sets the user code lifetime associated with the claims principal.

public static ClaimsPrincipal SetUserCodeLifetime(this ClaimsPrincipal principal, TimeSpan? lifetime)

Parameters

principal ClaimsPrincipal

The claims principal.

lifetime TimeSpan?

The user code lifetime to store.

Returns

ClaimsPrincipal

The claims principal.