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

## AuthServiceJwtFormatter Class

Provides functionality to format and sign JSON Web Tokens \(JWTs\) specifically for use within the authentication
service\. This class processes tokens issued by the authentication service itself, including access tokens,
refresh tokens and Registration Access Tokens generated during client registration via the dynamic registration API\.
It leverages signing and optional encryption to generate JWTs that authenticate and authorize internal service
operations\.

```csharp
public class AuthServiceJwtFormatter : Abblix.Oidc.Server.Features.Tokens.Formatters.IAuthServiceJwtFormatter
```

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

Implements [IAuthServiceJwtFormatter](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Tokens.Formatters.IAuthServiceJwtFormatter 'Abblix\.Oidc\.Server\.Features\.Tokens\.Formatters\.IAuthServiceJwtFormatter')
### Constructors

## AuthServiceJwtFormatter\(IJsonWebTokenCreator, IAuthServiceKeysProvider, IOptions\<OidcOptions\>\) Constructor {#Abblix.Oidc.Server.Features.Tokens.Formatters.AuthServiceJwtFormatter.AuthServiceJwtFormatter(Abblix.Jwt.IJsonWebTokenCreator,Abblix.Oidc.Server.Common.Interfaces.IAuthServiceKeysProvider,Microsoft.Extensions.Options.IOptions_Abblix.Oidc.Server.Common.Configuration.OidcOptions_)}

Provides functionality to format and sign JSON Web Tokens \(JWTs\) specifically for use within the authentication
service\. This class processes tokens issued by the authentication service itself, including access tokens,
refresh tokens and Registration Access Tokens generated during client registration via the dynamic registration API\.
It leverages signing and optional encryption to generate JWTs that authenticate and authorize internal service
operations\.

```csharp
public AuthServiceJwtFormatter(Abblix.Jwt.IJsonWebTokenCreator jwtCreator, Abblix.Oidc.Server.Common.Interfaces.IAuthServiceKeysProvider serviceKeysProvider, Microsoft.Extensions.Options.IOptions<Abblix.Oidc.Server.Common.Configuration.OidcOptions> options);
```
#### Parameters

###### `jwtCreator` [IJsonWebTokenCreator](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.IJsonWebTokenCreator 'Abblix\.Jwt\.IJsonWebTokenCreator') {#Abblix.Oidc.Server.Features.Tokens.Formatters.AuthServiceJwtFormatter.AuthServiceJwtFormatter(Abblix.Jwt.IJsonWebTokenCreator,Abblix.Oidc.Server.Common.Interfaces.IAuthServiceKeysProvider,Microsoft.Extensions.Options.IOptions_Abblix.Oidc.Server.Common.Configuration.OidcOptions_).jwtCreator}

The service responsible for creating and issuing JWTs\.

###### `serviceKeysProvider` [IAuthServiceKeysProvider](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.Interfaces.IAuthServiceKeysProvider 'Abblix\.Oidc\.Server\.Common\.Interfaces\.IAuthServiceKeysProvider') {#Abblix.Oidc.Server.Features.Tokens.Formatters.AuthServiceJwtFormatter.AuthServiceJwtFormatter(Abblix.Jwt.IJsonWebTokenCreator,Abblix.Oidc.Server.Common.Interfaces.IAuthServiceKeysProvider,Microsoft.Extensions.Options.IOptions_Abblix.Oidc.Server.Common.Configuration.OidcOptions_).serviceKeysProvider}

The provider that supplies cryptographic keys used for signing and
            encrypting JWTs\.

###### `options` [Microsoft\.Extensions\.Options\.IOptions&lt;](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.options.ioptions-1 'Microsoft\.Extensions\.Options\.IOptions\`1')[OidcOptions](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.Configuration.OidcOptions 'Abblix\.Oidc\.Server\.Common\.Configuration\.OidcOptions')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/microsoft.extensions.options.ioptions-1 'Microsoft\.Extensions\.Options\.IOptions\`1') {#Abblix.Oidc.Server.Features.Tokens.Formatters.AuthServiceJwtFormatter.AuthServiceJwtFormatter(Abblix.Jwt.IJsonWebTokenCreator,Abblix.Oidc.Server.Common.Interfaces.IAuthServiceKeysProvider,Microsoft.Extensions.Options.IOptions_Abblix.Oidc.Server.Common.Configuration.OidcOptions_).options}

OIDC configuration options\.
### Methods

## AuthServiceJwtFormatter\.FormatAsync\(JsonWebToken\) Method {#Abblix.Oidc.Server.Features.Tokens.Formatters.AuthServiceJwtFormatter.FormatAsync(Abblix.Jwt.JsonWebToken)}

Formats and signs a JWT for use by the authentication service, applying the appropriate cryptographic operations
based on the JWT specified requirements and the available cryptographic keys\.

```csharp
public System.Threading.Tasks.Task<string> FormatAsync(Abblix.Jwt.JsonWebToken token);
```
#### Parameters

###### `token` [JsonWebToken](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebToken 'Abblix\.Jwt\.JsonWebToken') {#Abblix.Oidc.Server.Features.Tokens.Formatters.AuthServiceJwtFormatter.FormatAsync(Abblix.Jwt.JsonWebToken).token}

The JSON Web Token \(JWT\) to be formatted and signed, potentially also encrypted\.

Implements [FormatAsync\(JsonWebToken\)](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Tokens.Formatters.IAuthServiceJwtFormatter#Abblix.Oidc.Server.Features.Tokens.Formatters.IAuthServiceJwtFormatter.FormatAsync(Abblix.Jwt.JsonWebToken) 'Abblix\.Oidc\.Server\.Features\.Tokens\.Formatters\.IAuthServiceJwtFormatter\.FormatAsync\(Abblix\.Jwt\.JsonWebToken\)')

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`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.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
A task that returns the JWT formatted
            as a string\.

### Remarks
This method selects the appropriate signing key based on the algorithm specified in the JWT header\.
If encryption is supported and keys are available, it also encrypts the JWT\. The result is a JWT string
that is ready for use in authenticating and authorizing service operations, including access tokens,
refresh tokens and Registration Access Tokens\.
