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

## IAuthServiceJwtFormatter Interface

Serializes a [JsonWebToken](https://www.abblix.com/docs/api/abblix-jwt/Abblix.Jwt.JsonWebToken 'Abblix\.Jwt\.JsonWebToken') minted by the authorization server itself \(access tokens, refresh
tokens, registration access tokens, initial access tokens\) into a compact JWS form \(RFC 7515\) using the
server's signing keys, and \- per an explicit [ServiceJwtEncryption](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryption 'Abblix\.Oidc\.Server\.Features\.Tokens\.Formatters\.ServiceJwtEncryption') policy \- optionally wraps
the result in a JWE \(RFC 7516\) encrypted to the server's own encryption key\.

```csharp
public interface IAuthServiceJwtFormatter
```

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

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

Formats and signs a JWT for use within the authentication service, applying cryptographic operations such as
signing and optionally encrypting the token based on the specified requirements\.

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

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

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

#### 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 representing the asynchronous operation, which results in the JWT formatted as a string\.

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

Formats and signs a JWT for use within the authentication service, and \- per the supplied
[encryption](https://www.abblix.com/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.ServiceJwtEncryption).encryption 'Abblix\.Oidc\.Server\.Features\.Tokens\.Formatters\.IAuthServiceJwtFormatter\.FormatAsync\(Abblix\.Jwt\.JsonWebToken, Abblix\.Oidc\.Server\.Features\.Tokens\.Formatters\.ServiceJwtEncryption\)\.encryption') policy \- optionally encrypts it as a JWE to the server's own encryption key\.
The signing algorithm and pinned signing key id come from the token header, set by the issuing service\.

```csharp
System.Threading.Tasks.Task<string> FormatAsync(Abblix.Jwt.JsonWebToken token, Abblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryption encryption);
```
#### Parameters

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

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

###### `encryption` [ServiceJwtEncryption](https://www.abblix.com/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryption 'Abblix\.Oidc\.Server\.Features\.Tokens\.Formatters\.ServiceJwtEncryption') {#Abblix.Oidc.Server.Features.Tokens.Formatters.IAuthServiceJwtFormatter.FormatAsync(Abblix.Jwt.JsonWebToken,Abblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryption).encryption}

The encryption policy: whether to encrypt, which key\-management algorithm and
            encryption key to use, and the content\-encryption algorithm\.

#### 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 representing the asynchronous operation, which results in the JWT formatted as a string\.
