Show / Hide Table of Contents

# Interface IOpenIddictTokenStore<TToken>

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

###### Namespace: OpenIddict.Abstractions

###### Assembly: cs.temp.dll.dll

##### Syntax

    public interface IOpenIddictTokenStore<TToken>
        where TToken : class

##### Type Parameters

Name | Description
--- | ---
TToken | The type of the Token entity.

### Methods

#### CountAsync(CancellationToken)

Determines the number of tokens that exist in the database.

##### Declaration

    ValueTask<long> CountAsync(CancellationToken cancellationToken)

##### Parameters

Type | Name | Description
--- | --- | ---
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<System.Int64> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.Func<IQueryable<TToken>, IQueryable<TResult>> | query | The query to execute.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<System.Int64> | A that can be used to monitor the asynchronous operation, whose result returns the number of tokens that match the specified query.

##### Type Parameters

Name | Description
--- | ---
TResult | The result type.

#### CreateAsync(TToken, CancellationToken)

Creates a new token.

##### Declaration

    ValueTask CreateAsync(TToken token, CancellationToken cancellationToken)

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token to create.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.

#### DeleteAsync(TToken, CancellationToken)

Removes a token.

##### Declaration

    ValueTask DeleteAsync(TToken token, CancellationToken cancellationToken)

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token to delete.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.

#### FindAsync(String, String, CancellationToken)

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

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | subject | The subject associated with the token.
System.String | client | The client associated with the token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
IAsyncEnumerable<TToken> | The tokens corresponding to the subject/client.

#### FindAsync(String, String, String, CancellationToken)

Retrieves the tokens matching the specified parameters.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | subject | The subject associated with the token.
System.String | client | The client associated with the token.
System.String | status | The token status.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
IAsyncEnumerable<TToken> | The tokens corresponding to the criteria.

#### FindAsync(String, String, String, String, CancellationToken)

Retrieves the tokens matching the specified parameters.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | subject | The subject associated with the token.
System.String | client | The client associated with the token.
System.String | status | The token status.
System.String | type | The token type.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
IAsyncEnumerable<TToken> | The tokens corresponding to the criteria.

#### FindByApplicationIdAsync(String, CancellationToken)

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

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | identifier | The application identifier associated with the tokens.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
IAsyncEnumerable<TToken> | The tokens corresponding to the specified application.

#### FindByAuthorizationIdAsync(String, CancellationToken)

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

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | identifier | The authorization identifier associated with the tokens.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
IAsyncEnumerable<TToken> | The tokens corresponding to the specified authorization.

#### FindByIdAsync(String, CancellationToken)

Retrieves a token using its unique identifier.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | identifier | The unique identifier associated with the token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<TToken> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | identifier | The reference identifier associated with the tokens.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<TToken> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.String | subject | The subject associated with the tokens.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
IAsyncEnumerable<TToken> | The tokens corresponding to the specified subject.

#### GetApplicationIdAsync(TToken, CancellationToken)

Retrieves the optional application identifier associated with a token.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<System.String> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.Func<IQueryable<TToken>, TState, IQueryable<TResult>> | query | The query to execute.
TState | state | The optional state.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<TResult> | A that can be used to monitor the asynchronous operation, whose result returns the first element returned when executing the query.

##### Type Parameters

Name | Description
--- | ---
TState | The state type.
TResult | The result type.

#### GetAuthorizationIdAsync(TToken, CancellationToken)

Retrieves the optional authorization identifier associated with a token.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<System.String> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<System.Nullable<System.DateTimeOffset>> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<System.Nullable<System.DateTimeOffset>> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<System.String> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<System.String> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<ImmutableDictionary<System.String, JsonElement>> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<System.Nullable<System.DateTimeOffset>> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<System.String> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<System.String> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<System.String> | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<System.String> | A 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.

##### Declaration

    ValueTask<TToken> InstantiateAsync(CancellationToken cancellationToken)

##### Parameters

Type | Name | Description
--- | --- | ---
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask<TToken> | A that can be used to monitor the asynchronous operation, whose result returns the instantiated token, that can be persisted in the database.

#### ListAsync(Nullable<Int32>, Nullable<Int32>, CancellationToken)

Executes the specified query and returns all the corresponding elements.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.Nullable<System.Int32> | count | The number of results to return.
System.Nullable<System.Int32> | offset | The number of results to skip.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
System.Func<IQueryable<TToken>, TState, IQueryable<TResult>> | query | The query to execute.
TState | state | The optional state.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
IAsyncEnumerable<TResult> | All the elements returned when executing the specified query.

##### Type Parameters

Name | Description
--- | ---
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.

##### Declaration

    ValueTask PruneAsync(DateTimeOffset threshold, CancellationToken cancellationToken)

##### Parameters

Type | Name | Description
--- | --- | ---
System.DateTimeOffset | threshold | The date before which tokens are not pruned.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.

#### SetApplicationIdAsync(TToken, String, CancellationToken)

Sets the application identifier associated with a token.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
System.String | identifier | The unique identifier associated with the token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.

#### SetAuthorizationIdAsync(TToken, String, CancellationToken)

Sets the authorization identifier associated with a token.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
System.String | identifier | The unique identifier associated with the token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.

#### SetCreationDateAsync(TToken, Nullable<DateTimeOffset>, CancellationToken)

Sets the creation date associated with a token.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
System.Nullable<System.DateTimeOffset> | date | The creation date.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.

#### SetExpirationDateAsync(TToken, Nullable<DateTimeOffset>, CancellationToken)

Sets the expiration date associated with a token.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
System.Nullable<System.DateTimeOffset> | date | The expiration date.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.

#### SetPayloadAsync(TToken, String, CancellationToken)

Sets the payload associated with a token.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
System.String | payload | The payload associated with the token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.

#### SetPropertiesAsync(TToken, ImmutableDictionary<String, JsonElement>, CancellationToken)

Sets the additional properties associated with a token.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
ImmutableDictionary<System.String, JsonElement> | properties | The additional properties associated with the token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.

#### SetRedemptionDateAsync(TToken, Nullable<DateTimeOffset>, CancellationToken)

Sets the redemption date associated with a token.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
System.Nullable<System.DateTimeOffset> | date | The redemption date.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A 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.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
System.String | identifier | The reference identifier associated with the token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.

#### SetStatusAsync(TToken, String, CancellationToken)

Sets the status associated with a token.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
System.String | status | The status associated with the authorization.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.

#### SetSubjectAsync(TToken, String, CancellationToken)

Sets the subject associated with a token.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
System.String | subject | The subject associated with the token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.

#### SetTypeAsync(TToken, String, CancellationToken)

Sets the token type associated with a token.

##### Declaration

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

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token.
System.String | type | The token type associated with the token.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.

#### UpdateAsync(TToken, CancellationToken)

Updates an existing token.

##### Declaration

    ValueTask UpdateAsync(TToken token, CancellationToken cancellationToken)

##### Parameters

Type | Name | Description
--- | --- | ---
TToken | token | The token to update.
CancellationToken | cancellationToken | The that can be used to abort the operation.

##### Returns

Type | Description
--- | ---
ValueTask | A that can be used to monitor the asynchronous operation.