#### [Abblix\.Oidc\.Server](https://www.abblix.com/en/docs/api/abblix-oidc-server 'index')
### [Abblix\.Oidc\.Server\.Endpoints\.Token\.Interfaces](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Endpoints.Token.Interfaces 'Abblix\.Oidc\.Server\.Endpoints\.Token\.Interfaces')

## ITokenHandler Interface

Defines a contract for handling OAuth 2\.0 token requests, encompassing validation, processing, and issuance
of tokens based on authorization grants\.

```csharp
public interface ITokenHandler
```

Derived  
↳ [TokenHandler](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Endpoints.Token.TokenHandler 'Abblix\.Oidc\.Server\.Endpoints\.Token\.TokenHandler')
### Methods

## ITokenHandler\.HandleAsync\(TokenRequest, ClientRequest\) Method {#Abblix.Oidc.Server.Endpoints.Token.Interfaces.ITokenHandler.HandleAsync(Abblix.Oidc.Server.Model.TokenRequest,Abblix.Oidc.Server.Model.ClientRequest)}

Asynchronously handles a token request, validating the request details and, if valid, processing it to issue,
renew or exchange tokens according to OAuth 2\.0 and OpenID Connect standards\.

```csharp
System.Threading.Tasks.Task<Abblix.Utils.Result<Abblix.Oidc.Server.Endpoints.Token.Interfaces.TokenIssued,Abblix.Oidc.Server.Common.OidcError>> HandleAsync(Abblix.Oidc.Server.Model.TokenRequest tokenRequest, Abblix.Oidc.Server.Model.ClientRequest clientRequest);
```
#### Parameters

###### `tokenRequest` [TokenRequest](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Model.TokenRequest 'Abblix\.Oidc\.Server\.Model\.TokenRequest') {#Abblix.Oidc.Server.Endpoints.Token.Interfaces.ITokenHandler.HandleAsync(Abblix.Oidc.Server.Model.TokenRequest,Abblix.Oidc.Server.Model.ClientRequest).tokenRequest}

The token request containing essential parameters such as the grant type,
            client credentials, and other parameters pertinent to the token issuance process\.

###### `clientRequest` [ClientRequest](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Model.ClientRequest 'Abblix\.Oidc\.Server\.Model\.ClientRequest') {#Abblix.Oidc.Server.Endpoints.Token.Interfaces.ITokenHandler.HandleAsync(Abblix.Oidc.Server.Model.TokenRequest,Abblix.Oidc.Server.Model.ClientRequest).clientRequest}

Supplementary information about the client making the request, necessary
            for performing contextual validation and ensuring the request complies with security policies\.

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[Abblix\.Utils\.Result&lt;](https://learn.microsoft.com/en-us/dotnet/api/abblix.utils.result-2 'Abblix\.Utils\.Result\`2')[TokenIssued](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Endpoints.Token.Interfaces.TokenIssued 'Abblix\.Oidc\.Server\.Endpoints\.Token\.Interfaces\.TokenIssued')[,](https://learn.microsoft.com/en-us/dotnet/api/abblix.utils.result-2 'Abblix\.Utils\.Result\`2')[OidcError](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.OidcError 'Abblix\.Oidc\.Server\.Common\.OidcError')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/abblix.utils.result-2 'Abblix\.Utils\.Result\`2')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
A [System\.Threading\.Tasks\.Task](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task 'System\.Threading\.Tasks\.Task') resulting in a [TokenIssued](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Endpoints.Token.Interfaces.TokenIssued 'Abblix\.Oidc\.Server\.Endpoints\.Token\.Interfaces\.TokenIssued') on success — which contains the issued tokens
\(access token, refresh token, ID token, etc\.\) — or an [OidcError](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.OidcError 'Abblix\.Oidc\.Server\.Common\.OidcError') describing the reason
for request failure\.

### Remarks
Implementations of this interface are critical to the secure and compliant functioning of an OAuth 2\.0
authorization server\. They must ensure that only valid and authorized requests lead to the issuance of tokens,
thereby maintaining the integrity and security of the authentication and authorization process\.
