#### [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')

## ServiceJwtEncryptionExtensions Class

Completes a [ServiceJwtEncryption](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryption 'Abblix\.Oidc\.Server\.Features\.Tokens\.Formatters\.ServiceJwtEncryption') policy from the request it is about to serve\.

```csharp
public static class ServiceJwtEncryptionExtensions
```

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

## ServiceJwtEncryptionExtensions\.WithAudienceKeyAsync\(this ServiceJwtEncryption, AuthorizationContext, IAudienceKeyResolver\) Method {#Abblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryptionExtensions.WithAudienceKeyAsync(thisAbblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryption,Abblix.Oidc.Server.Common.AuthorizationContext,Abblix.Oidc.Server.Features.ResourceIndicators.IAudienceKeyResolver)}

Points the policy at the key published by the resource this token was minted for, so the party named in
`aud` can read it\.

```csharp
public static System.Threading.Tasks.Task<Abblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryption> WithAudienceKeyAsync(this Abblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryption encryption, Abblix.Oidc.Server.Common.AuthorizationContext context, Abblix.Oidc.Server.Features.ResourceIndicators.IAudienceKeyResolver audienceKeys);
```
#### Parameters

###### `encryption` [ServiceJwtEncryption](https://www.abblix.com/en/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.ServiceJwtEncryptionExtensions.WithAudienceKeyAsync(thisAbblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryption,Abblix.Oidc.Server.Common.AuthorizationContext,Abblix.Oidc.Server.Features.ResourceIndicators.IAudienceKeyResolver).encryption}

The policy projected from the server's own settings\.

###### `context` [AuthorizationContext](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.AuthorizationContext 'Abblix\.Oidc\.Server\.Common\.AuthorizationContext') {#Abblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryptionExtensions.WithAudienceKeyAsync(thisAbblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryption,Abblix.Oidc.Server.Common.AuthorizationContext,Abblix.Oidc.Server.Features.ResourceIndicators.IAudienceKeyResolver).context}

The authorization context naming the token's audience\.

###### `audienceKeys` [IAudienceKeyResolver](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.ResourceIndicators.IAudienceKeyResolver 'Abblix\.Oidc\.Server\.Features\.ResourceIndicators\.IAudienceKeyResolver') {#Abblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryptionExtensions.WithAudienceKeyAsync(thisAbblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryption,Abblix.Oidc.Server.Common.AuthorizationContext,Abblix.Oidc.Server.Features.ResourceIndicators.IAudienceKeyResolver).audienceKeys}

Answers which key, if any, the named audience published\.

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[ServiceJwtEncryption](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.Tokens.Formatters.ServiceJwtEncryption 'Abblix\.Oidc\.Server\.Features\.Tokens\.Formatters\.ServiceJwtEncryption')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
The policy, pointed at the audience's key where one is published\.

### Remarks
An audience that publishes no key leaves the policy untouched, which is how it says a signed JWS is
what it expects\. What makes a set of resources publish one key or none is
[IAudienceKeyResolver](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Features.ResourceIndicators.IAudienceKeyResolver 'Abblix\.Oidc\.Server\.Features\.ResourceIndicators\.IAudienceKeyResolver')'s question\.
