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

## JsonWebKeyExtensions Class

Provides extensions for asynchronous operations on a sequence of [JsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.JsonWebKey') objects\.

```csharp
public static class JsonWebKeyExtensions
```

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

## JsonWebKeyExtensions\.FirstByAlgorithmAsync\(this IAsyncEnumerable\<JsonWebKey\>, string\) Method {#Abblix.Oidc.Server.Common.JsonWebKeyExtensions.FirstByAlgorithmAsync(thisSystem.Collections.Generic.IAsyncEnumerable_Abblix.Jwt.JsonWebKey_,string)}

Asynchronously retrieves the first [JsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.JsonWebKey') with the specified algorithm from the sequence\.
Prioritizes keys with exact algorithm match, then falls back to algorithm\-agnostic keys \(Algorithm == null\)
per RFC 7517, which allows keys without 'alg' parameter to be used with any compatible algorithm\.

```csharp
public static System.Threading.Tasks.Task<Abblix.Jwt.JsonWebKey?> FirstByAlgorithmAsync(this System.Collections.Generic.IAsyncEnumerable<Abblix.Jwt.JsonWebKey> credentials, string? algorithm);
```
#### Parameters

###### `credentials` [System\.Collections\.Generic\.IAsyncEnumerable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1 'System\.Collections\.Generic\.IAsyncEnumerable\`1')[JsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.JsonWebKey')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.iasyncenumerable-1 'System\.Collections\.Generic\.IAsyncEnumerable\`1') {#Abblix.Oidc.Server.Common.JsonWebKeyExtensions.FirstByAlgorithmAsync(thisSystem.Collections.Generic.IAsyncEnumerable_Abblix.Jwt.JsonWebKey_,string).credentials}

The asynchronous sequence of [JsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.JsonWebKey') objects\.

###### `algorithm` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Common.JsonWebKeyExtensions.FirstByAlgorithmAsync(thisSystem.Collections.Generic.IAsyncEnumerable_Abblix.Jwt.JsonWebKey_,string).algorithm}

The algorithm to match\. Returns null if [None](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.SigningAlgorithms#Abblix.Jwt.SigningAlgorithms.None 'Abblix\.Jwt\.SigningAlgorithms\.None') is provided\.

#### Returns
[System\.Threading\.Tasks\.Task&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')[JsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.JsonWebKey')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task-1 'System\.Threading\.Tasks\.Task\`1')  
The first [JsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.JsonWebKey 'Abblix\.Jwt\.JsonWebKey') with the specified algorithm or null if not found\.
