Table of Contents

Interface IOpenIddictTokenStore<TToken>

Namespace
OpenIddict.Abstractions
Assembly
OpenIddict.Abstractions.dll

Provides methods allowing to manage the tokens stored in a database.

public interface IOpenIddictTokenStore<TToken> where TToken : class

Type Parameters

TToken

The type of the Token entity.

Methods

CountAsync(CancellationToken)

Determines the number of tokens that exist in the database.

ValueTask<long> CountAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<long>

A ValueTask that can be used to monitor the asynchronous operation, whose result returns the number of applications in the database.

CountAsync<TResult>(Func<IQueryable<TToken>, IQueryable<TResult>>, CancellationToken)

Determines the number of tokens that match the specified query.

ValueTask<long> CountAsync<TResult>(Func<IQueryable<TToken>, IQueryable<TResult>> query, CancellationToken cancellationToken)

Parameters

query Func<IQueryable<TToken>, IQueryable<TResult>>

The query to execute.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<long>

A ValueTask that can be used to monitor the asynchronous operation, whose result returns the number of tokens that match the specified query.

Type Parameters

TResult

The result type.

CreateAsync(TToken, CancellationToken)

Creates a new token.

ValueTask CreateAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token to create.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

DeleteAsync(TToken, CancellationToken)

Removes a token.

ValueTask DeleteAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token to delete.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

FindAsync(string, string, string, string, CancellationToken)

Retrieves the tokens matching the specified parameters.

IAsyncEnumerable<TToken> FindAsync(string subject, string client, string status, string type, CancellationToken cancellationToken)

Parameters

subject string

The subject associated with the token.

client string

The client associated with the token.

status string

The token status.

type string

The token type.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<TToken>

The tokens corresponding to the criteria.

FindAsync(string, string, string, CancellationToken)

Retrieves the tokens matching the specified parameters.

IAsyncEnumerable<TToken> FindAsync(string subject, string client, string status, CancellationToken cancellationToken)

Parameters

subject string

The subject associated with the token.

client string

The client associated with the token.

status string

The token status.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<TToken>

The tokens corresponding to the criteria.

FindAsync(string, string, CancellationToken)

Retrieves the tokens corresponding to the specified subject and associated with the application identifier.

IAsyncEnumerable<TToken> FindAsync(string subject, string client, CancellationToken cancellationToken)

Parameters

subject string

The subject associated with the token.

client string

The client associated with the token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<TToken>

The tokens corresponding to the subject/client.

FindByApplicationIdAsync(string, CancellationToken)

Retrieves the list of tokens corresponding to the specified application identifier.

IAsyncEnumerable<TToken> FindByApplicationIdAsync(string identifier, CancellationToken cancellationToken)

Parameters

identifier string

The application identifier associated with the tokens.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<TToken>

The tokens corresponding to the specified application.

FindByAuthorizationIdAsync(string, CancellationToken)

Retrieves the list of tokens corresponding to the specified authorization identifier.

IAsyncEnumerable<TToken> FindByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken)

Parameters

identifier string

The authorization identifier associated with the tokens.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<TToken>

The tokens corresponding to the specified authorization.

FindByIdAsync(string, CancellationToken)

Retrieves a token using its unique identifier.

ValueTask<TToken?> FindByIdAsync(string identifier, CancellationToken cancellationToken)

Parameters

identifier string

The unique identifier associated with the token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<TToken>

A ValueTask that can be used to monitor the asynchronous operation, whose result returns the token corresponding to the unique identifier.

FindByReferenceIdAsync(string, CancellationToken)

Retrieves the list of tokens corresponding to the specified reference identifier. Note: the reference identifier may be hashed or encrypted for security reasons.

ValueTask<TToken?> FindByReferenceIdAsync(string identifier, CancellationToken cancellationToken)

Parameters

identifier string

The reference identifier associated with the tokens.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<TToken>

A ValueTask that can be used to monitor the asynchronous operation, whose result returns the tokens corresponding to the specified reference identifier.

FindBySubjectAsync(string, CancellationToken)

Retrieves the list of tokens corresponding to the specified subject.

IAsyncEnumerable<TToken> FindBySubjectAsync(string subject, CancellationToken cancellationToken)

Parameters

subject string

The subject associated with the tokens.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<TToken>

The tokens corresponding to the specified subject.

GetApplicationIdAsync(TToken, CancellationToken)

Retrieves the optional application identifier associated with a token.

ValueTask<string?> GetApplicationIdAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<string>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the application identifier associated with the token.

GetAsync<TState, TResult>(Func<IQueryable<TToken>, TState, IQueryable<TResult>>, TState, CancellationToken)

Executes the specified query and returns the first element.

ValueTask<TResult?> GetAsync<TState, TResult>(Func<IQueryable<TToken>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)

Parameters

query Func<IQueryable<TToken>, TState, IQueryable<TResult>>

The query to execute.

state TState

The optional state.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<TResult>

A ValueTask that can be used to monitor the asynchronous operation, whose result returns the first element returned when executing the query.

Type Parameters

TState

The state type.

TResult

The result type.

GetAuthorizationIdAsync(TToken, CancellationToken)

Retrieves the optional authorization identifier associated with a token.

ValueTask<string?> GetAuthorizationIdAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<string>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the authorization identifier associated with the token.

GetCreationDateAsync(TToken, CancellationToken)

Retrieves the creation date associated with a token.

ValueTask<DateTimeOffset?> GetCreationDateAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<DateTimeOffset?>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the creation date associated with the specified token.

GetExpirationDateAsync(TToken, CancellationToken)

Retrieves the expiration date associated with a token.

ValueTask<DateTimeOffset?> GetExpirationDateAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<DateTimeOffset?>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the expiration date associated with the specified token.

GetIdAsync(TToken, CancellationToken)

Retrieves the unique identifier associated with a token.

ValueTask<string?> GetIdAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<string>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the unique identifier associated with the token.

GetPayloadAsync(TToken, CancellationToken)

Retrieves the payload associated with a token.

ValueTask<string?> GetPayloadAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<string>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the payload associated with the specified token.

GetPropertiesAsync(TToken, CancellationToken)

Retrieves the additional properties associated with a token.

ValueTask<ImmutableDictionary<string, JsonElement>> GetPropertiesAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<ImmutableDictionary<string, JsonElement>>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns all the additional properties associated with the token.

GetRedemptionDateAsync(TToken, CancellationToken)

Retrieves the redemption date associated with a token.

ValueTask<DateTimeOffset?> GetRedemptionDateAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<DateTimeOffset?>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the redemption date associated with the specified token.

GetReferenceIdAsync(TToken, CancellationToken)

Retrieves the reference identifier associated with a token. Note: depending on the manager used to create the token, the reference identifier may be hashed for security reasons.

ValueTask<string?> GetReferenceIdAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<string>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the reference identifier associated with the specified token.

GetStatusAsync(TToken, CancellationToken)

Retrieves the status associated with a token.

ValueTask<string?> GetStatusAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<string>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the status associated with the specified token.

GetSubjectAsync(TToken, CancellationToken)

Retrieves the subject associated with a token.

ValueTask<string?> GetSubjectAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<string>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the subject associated with the specified token.

GetTypeAsync(TToken, CancellationToken)

Retrieves the token type associated with a token.

ValueTask<string?> GetTypeAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<string>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the token type associated with the specified token.

InstantiateAsync(CancellationToken)

Instantiates a new token.

ValueTask<TToken> InstantiateAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<TToken>

A ValueTask<TResult> that can be used to monitor the asynchronous operation, whose result returns the instantiated token, that can be persisted in the database.

ListAsync(int?, int?, CancellationToken)

Executes the specified query and returns all the corresponding elements.

IAsyncEnumerable<TToken> ListAsync(int? count, int? offset, CancellationToken cancellationToken)

Parameters

count int?

The number of results to return.

offset int?

The number of results to skip.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<TToken>

All the elements returned when executing the specified query.

ListAsync<TState, TResult>(Func<IQueryable<TToken>, TState, IQueryable<TResult>>, TState, CancellationToken)

Executes the specified query and returns all the corresponding elements.

IAsyncEnumerable<TResult> ListAsync<TState, TResult>(Func<IQueryable<TToken>, TState, IQueryable<TResult>> query, TState state, CancellationToken cancellationToken)

Parameters

query Func<IQueryable<TToken>, TState, IQueryable<TResult>>

The query to execute.

state TState

The optional state.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

IAsyncEnumerable<TResult>

All the elements returned when executing the specified query.

Type Parameters

TState

The state type.

TResult

The result type.

PruneAsync(DateTimeOffset, CancellationToken)

Removes the tokens that are marked as invalid or whose attached authorization is no longer valid. Only tokens created before the specified threshold are removed.

ValueTask<long> PruneAsync(DateTimeOffset threshold, CancellationToken cancellationToken)

Parameters

threshold DateTimeOffset

The date before which tokens are not pruned.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<long>

The number of tokens that were removed.

RevokeByAuthorizationIdAsync(string, CancellationToken)

Revokes all the tokens associated with the specified authorization identifier.

ValueTask<long> RevokeByAuthorizationIdAsync(string identifier, CancellationToken cancellationToken)

Parameters

identifier string

The authorization identifier associated with the tokens.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask<long>

The number of tokens associated with the specified authorization that were marked as revoked.

SetApplicationIdAsync(TToken, string?, CancellationToken)

Sets the application identifier associated with a token.

ValueTask SetApplicationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken)

Parameters

token TToken

The token.

identifier string

The unique identifier associated with the token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

SetAuthorizationIdAsync(TToken, string?, CancellationToken)

Sets the authorization identifier associated with a token.

ValueTask SetAuthorizationIdAsync(TToken token, string? identifier, CancellationToken cancellationToken)

Parameters

token TToken

The token.

identifier string

The unique identifier associated with the token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

SetCreationDateAsync(TToken, DateTimeOffset?, CancellationToken)

Sets the creation date associated with a token.

ValueTask SetCreationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken)

Parameters

token TToken

The token.

date DateTimeOffset?

The creation date.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

SetExpirationDateAsync(TToken, DateTimeOffset?, CancellationToken)

Sets the expiration date associated with a token.

ValueTask SetExpirationDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken)

Parameters

token TToken

The token.

date DateTimeOffset?

The expiration date.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

SetPayloadAsync(TToken, string?, CancellationToken)

Sets the payload associated with a token.

ValueTask SetPayloadAsync(TToken token, string? payload, CancellationToken cancellationToken)

Parameters

token TToken

The token.

payload string

The payload associated with the token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

SetPropertiesAsync(TToken, ImmutableDictionary<string, JsonElement>, CancellationToken)

Sets the additional properties associated with a token.

ValueTask SetPropertiesAsync(TToken token, ImmutableDictionary<string, JsonElement> properties, CancellationToken cancellationToken)

Parameters

token TToken

The token.

properties ImmutableDictionary<string, JsonElement>

The additional properties associated with the token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

SetRedemptionDateAsync(TToken, DateTimeOffset?, CancellationToken)

Sets the redemption date associated with a token.

ValueTask SetRedemptionDateAsync(TToken token, DateTimeOffset? date, CancellationToken cancellationToken)

Parameters

token TToken

The token.

date DateTimeOffset?

The redemption date.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

SetReferenceIdAsync(TToken, string?, CancellationToken)

Sets the reference identifier associated with a token. Note: depending on the manager used to create the token, the reference identifier may be hashed for security reasons.

ValueTask SetReferenceIdAsync(TToken token, string? identifier, CancellationToken cancellationToken)

Parameters

token TToken

The token.

identifier string

The reference identifier associated with the token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

SetStatusAsync(TToken, string?, CancellationToken)

Sets the status associated with a token.

ValueTask SetStatusAsync(TToken token, string? status, CancellationToken cancellationToken)

Parameters

token TToken

The token.

status string

The status associated with the authorization.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

SetSubjectAsync(TToken, string?, CancellationToken)

Sets the subject associated with a token.

ValueTask SetSubjectAsync(TToken token, string? subject, CancellationToken cancellationToken)

Parameters

token TToken

The token.

subject string

The subject associated with the token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

SetTypeAsync(TToken, string?, CancellationToken)

Sets the token type associated with a token.

ValueTask SetTypeAsync(TToken token, string? type, CancellationToken cancellationToken)

Parameters

token TToken

The token.

type string

The token type associated with the token.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.

UpdateAsync(TToken, CancellationToken)

Updates an existing token.

ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken)

Parameters

token TToken

The token to update.

cancellationToken CancellationToken

The CancellationToken that can be used to abort the operation.

Returns

ValueTask

A ValueTask that can be used to monitor the asynchronous operation.