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

## ClientCredentialsGrantHandler Class

Handles the authorization process for the client credentials grant type within the OAuth 2\.0 framework\.
This grant type is designed for machine\-to\-machine \(M2M\) authentication where the client itself is the resource owner\.
There is no end\-user involved in this flow \- the client uses its own credentials to obtain an access token
directly from the authorization server\.

```csharp
public class ClientCredentialsGrantHandler : Abblix.Oidc.Server.Endpoints.Token.Grants.IAuthorizationGrantHandler, Abblix.Oidc.Server.Common.Interfaces.IGrantTypeInformer
```

Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → ClientCredentialsGrantHandler

Implements [IAuthorizationGrantHandler](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Endpoints.Token.Grants.IAuthorizationGrantHandler 'Abblix\.Oidc\.Server\.Endpoints\.Token\.Grants\.IAuthorizationGrantHandler'), [IGrantTypeInformer](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.Interfaces.IGrantTypeInformer 'Abblix\.Oidc\.Server\.Common\.Interfaces\.IGrantTypeInformer')

### Remarks
The client credentials grant type is specified in RFC 6749 Section 4\.4\.
It is typically used in scenarios such as:
\- Backend services accessing APIs
\- Scheduled jobs or automated tasks
\- Microservice\-to\-microservice communication
\- CI/CD pipelines
The client must authenticate itself before this handler is invoked, using methods such as
client\_secret\_basic, client\_secret\_post, or private\_key\_jwt\.
### Constructors

## ClientCredentialsGrantHandler\(ISessionIdGenerator, TimeProvider\) Constructor {#Abblix.Oidc.Server.Endpoints.Token.Grants.ClientCredentialsGrantHandler.ClientCredentialsGrantHandler(Abblix.Oidc.Server.Features.RandomGenerators.ISessionIdGenerator,System.TimeProvider)}

Handles the authorization process for the client credentials grant type within the OAuth 2\.0 framework\.
This grant type is designed for machine\-to\-machine \(M2M\) authentication where the client itself is the resource owner\.
There is no end\-user involved in this flow \- the client uses its own credentials to obtain an access token
directly from the authorization server\.

```csharp
public ClientCredentialsGrantHandler(Abblix.Oidc.Server.Features.RandomGenerators.ISessionIdGenerator sessionIdGenerator, System.TimeProvider timeProvider);
```
#### Parameters

###### `sessionIdGenerator` [ISessionIdGenerator](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.RandomGenerators.ISessionIdGenerator 'Abblix\.Oidc\.Server\.Features\.RandomGenerators\.ISessionIdGenerator') {#Abblix.Oidc.Server.Endpoints.Token.Grants.ClientCredentialsGrantHandler.ClientCredentialsGrantHandler(Abblix.Oidc.Server.Features.RandomGenerators.ISessionIdGenerator,System.TimeProvider).sessionIdGenerator}

Generates unique session identifiers for authentication sessions\.

###### `timeProvider` [System\.TimeProvider](https://learn.microsoft.com/en-us/dotnet/api/system.timeprovider 'System\.TimeProvider') {#Abblix.Oidc.Server.Endpoints.Token.Grants.ClientCredentialsGrantHandler.ClientCredentialsGrantHandler(Abblix.Oidc.Server.Features.RandomGenerators.ISessionIdGenerator,System.TimeProvider).timeProvider}

Provides access to the current time for session timestamps\.

### Remarks
The client credentials grant type is specified in RFC 6749 Section 4\.4\.
It is typically used in scenarios such as:
\- Backend services accessing APIs
\- Scheduled jobs or automated tasks
\- Microservice\-to\-microservice communication
\- CI/CD pipelines
The client must authenticate itself before this handler is invoked, using methods such as
client\_secret\_basic, client\_secret\_post, or private\_key\_jwt\.
### Properties

## ClientCredentialsGrantHandler\.GrantTypesSupported Property {#Abblix.Oidc.Server.Endpoints.Token.Grants.ClientCredentialsGrantHandler.GrantTypesSupported}

Specifies the grant type that this handler supports, which is the "client\_credentials" grant type\.
This ensures that this handler is only invoked when processing requests with the client credentials grant type\.

```csharp
public System.Collections.Generic.IEnumerable<string> GrantTypesSupported { get; }
```

Implements [GrantTypesSupported](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.Interfaces.IGrantTypeInformer#Abblix.Oidc.Server.Common.Interfaces.IGrantTypeInformer.GrantTypesSupported 'Abblix\.Oidc\.Server\.Common\.Interfaces\.IGrantTypeInformer\.GrantTypesSupported')

#### Property Value
[System\.Collections\.Generic\.IEnumerable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ienumerable-1 'System\.Collections\.Generic\.IEnumerable\`1')
### Methods

## ClientCredentialsGrantHandler\.AuthorizeAsync\(TokenRequest, ClientInfo\) Method {#Abblix.Oidc.Server.Endpoints.Token.Grants.ClientCredentialsGrantHandler.AuthorizeAsync(Abblix.Oidc.Server.Model.TokenRequest,Abblix.Oidc.Server.Features.ClientInformation.ClientInfo)}

Asynchronously processes the token request using the client credentials grant type\.
Since the client has already been authenticated \(via client authentication middleware\),
this handler creates a grant for the client with the requested scope\.

```csharp
public System.Threading.Tasks.Task<Abblix.Utils.Result<Abblix.Oidc.Server.Endpoints.Token.Interfaces.AuthorizedGrant,Abblix.Oidc.Server.Common.OidcError>> AuthorizeAsync(Abblix.Oidc.Server.Model.TokenRequest request, Abblix.Oidc.Server.Features.ClientInformation.ClientInfo clientInfo);
```
#### Parameters

###### `request` [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.Grants.ClientCredentialsGrantHandler.AuthorizeAsync(Abblix.Oidc.Server.Model.TokenRequest,Abblix.Oidc.Server.Features.ClientInformation.ClientInfo).request}

The token request containing the requested scope and other parameters\.

###### `clientInfo` [ClientInfo](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.ClientInformation.ClientInfo 'Abblix\.Oidc\.Server\.Features\.ClientInformation\.ClientInfo') {#Abblix.Oidc.Server.Endpoints.Token.Grants.ClientCredentialsGrantHandler.AuthorizeAsync(Abblix.Oidc.Server.Model.TokenRequest,Abblix.Oidc.Server.Features.ClientInformation.ClientInfo).clientInfo}

Information about the authenticated client making the request\.

Implements [AuthorizeAsync\(TokenRequest, ClientInfo\)](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Endpoints.Token.Grants.IAuthorizationGrantHandler#Abblix.Oidc.Server.Endpoints.Token.Grants.IAuthorizationGrantHandler.AuthorizeAsync(Abblix.Oidc.Server.Model.TokenRequest,Abblix.Oidc.Server.Features.ClientInformation.ClientInfo) 'Abblix\.Oidc\.Server\.Endpoints\.Token\.Grants\.IAuthorizationGrantHandler\.AuthorizeAsync\(Abblix\.Oidc\.Server\.Model\.TokenRequest, Abblix\.Oidc\.Server\.Features\.ClientInformation\.ClientInfo\)')

#### 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')[AuthorizedGrant](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Endpoints.Token.Interfaces.AuthorizedGrant 'Abblix\.Oidc\.Server\.Endpoints\.Token\.Interfaces\.AuthorizedGrant')[,](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 task that completes with an authorized grant containing the client session and context\.
