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

## WwwAuthenticateBuilder Class

Builds `WWW-Authenticate` challenge values for the Bearer scheme \(RFC 6750 §3\)
and the DPoP scheme \(RFC 9449 §7\.1\)\. Endpoint\-agnostic and framework\-agnostic so the
same emission logic serves UserInfo, introspection, revocation, and any future
protected endpoint, regardless of whether the host is ASP\.NET Core MVC, minimal APIs,
or another framework altogether\.

```csharp
public static class WwwAuthenticateBuilder
```

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

### Remarks
The Bearer challenge attaches `error` / `error_description` when the inbound
failure is in fact a Bearer\-token failure \(`invalid_token`, `insufficient_scope`\)\.
When the failure is a DPoP\-specific error and Bearer is advertised alongside DPoP, the
Bearer line carries only the realm — RFC 9449 §7\.1 example: «the Bearer scheme didn't
fail; the client used the DPoP scheme», so attaching `error="invalid_dpop_proof"`
to the Bearer line would be misleading\.
### Methods

## WwwAuthenticateBuilder\.BuildBasicChallenge\(string\) Method {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildBasicChallenge(string)}

Builds a `WWW-Authenticate: Basic` challenge per RFC 7617 §2 for client\-authentication
failures \(RFC 6749 §5\.2\)\. Only the realm parameter is emitted: unlike Bearer \(RFC 6750 §3\),
the Basic scheme defines no error attributes, so the error itself stays in the JSON body\.

```csharp
public static string BuildBasicChallenge(string? realm);
```
#### Parameters

###### `realm` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildBasicChallenge(string).realm}

#### Returns
[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')

## WwwAuthenticateBuilder\.BuildBearerChallenge\(OidcError, string, bool\) Method {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildBearerChallenge(Abblix.Oidc.Server.Common.OidcError,string,bool)}

Builds a `WWW-Authenticate: Bearer` challenge per RFC 6750 §3\. The `error`
and `error_description` attributes are emitted only when the inbound failure is
a Bearer\-scheme failure; pass [includeError](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.WwwAuthenticateBuilder#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildBearerChallenge(Abblix.Oidc.Server.Common.OidcError,string,bool).includeError 'Abblix\.Oidc\.Server\.Common\.WwwAuthenticateBuilder\.BuildBearerChallenge\(Abblix\.Oidc\.Server\.Common\.OidcError, string, bool\)\.includeError') as `false` for
dual\-scheme responses where the Bearer line is informational\.

```csharp
public static string BuildBearerChallenge(Abblix.Oidc.Server.Common.OidcError error, string? realm, bool includeError=true);
```
#### Parameters

###### `error` [OidcError](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.OidcError 'Abblix\.Oidc\.Server\.Common\.OidcError') {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildBearerChallenge(Abblix.Oidc.Server.Common.OidcError,string,bool).error}

###### `realm` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildBearerChallenge(Abblix.Oidc.Server.Common.OidcError,string,bool).realm}

###### `includeError` [System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean') {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildBearerChallenge(Abblix.Oidc.Server.Common.OidcError,string,bool).includeError}

#### Returns
[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')

## WwwAuthenticateBuilder\.BuildChallenges\(OidcError, string, IEnumerable\<string\>, bool\) Method {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildChallenges(Abblix.Oidc.Server.Common.OidcError,string,System.Collections.Generic.IEnumerable_string_,bool)}

Builds the full set of `WWW-Authenticate` challenge lines for an error
response\. Returns DPoP first, Bearer second \(matching the RFC 9449 §7\.1 example
ordering\) when both schemes are advertised\.

```csharp
public static System.Collections.Generic.IReadOnlyList<string> BuildChallenges(Abblix.Oidc.Server.Common.OidcError error, string? realm, System.Collections.Generic.IEnumerable<string> dpopAlgs, bool advertiseBearer);
```
#### Parameters

###### `error` [OidcError](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.OidcError 'Abblix\.Oidc\.Server\.Common\.OidcError') {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildChallenges(Abblix.Oidc.Server.Common.OidcError,string,System.Collections.Generic.IEnumerable_string_,bool).error}

###### `realm` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildChallenges(Abblix.Oidc.Server.Common.OidcError,string,System.Collections.Generic.IEnumerable_string_,bool).realm}

###### `dpopAlgs` [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') {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildChallenges(Abblix.Oidc.Server.Common.OidcError,string,System.Collections.Generic.IEnumerable_string_,bool).dpopAlgs}

###### `advertiseBearer` [System\.Boolean](https://learn.microsoft.com/en-us/dotnet/api/system.boolean 'System\.Boolean') {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildChallenges(Abblix.Oidc.Server.Common.OidcError,string,System.Collections.Generic.IEnumerable_string_,bool).advertiseBearer}

#### Returns
[System\.Collections\.Generic\.IReadOnlyList&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.collections.generic.ireadonlylist-1 'System\.Collections\.Generic\.IReadOnlyList\`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.ireadonlylist-1 'System\.Collections\.Generic\.IReadOnlyList\`1')

## WwwAuthenticateBuilder\.BuildDPoPChallenge\(OidcError, string, IEnumerable\<string\>\) Method {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildDPoPChallenge(Abblix.Oidc.Server.Common.OidcError,string,System.Collections.Generic.IEnumerable_string_)}

Builds a `WWW-Authenticate: DPoP` challenge per RFC 9449 §7\.1, advertising the
JWS algorithms the AS accepts on a proof\.

```csharp
public static string BuildDPoPChallenge(Abblix.Oidc.Server.Common.OidcError error, string? realm, System.Collections.Generic.IEnumerable<string> algs);
```
#### Parameters

###### `error` [OidcError](https://www.abblix.com/en/docs/api/abblix-oidc-server/Abblix.Oidc.Server.Common.OidcError 'Abblix\.Oidc\.Server\.Common\.OidcError') {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildDPoPChallenge(Abblix.Oidc.Server.Common.OidcError,string,System.Collections.Generic.IEnumerable_string_).error}

###### `realm` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildDPoPChallenge(Abblix.Oidc.Server.Common.OidcError,string,System.Collections.Generic.IEnumerable_string_).realm}

###### `algs` [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') {#Abblix.Oidc.Server.Common.WwwAuthenticateBuilder.BuildDPoPChallenge(Abblix.Oidc.Server.Common.OidcError,string,System.Collections.Generic.IEnumerable_string_).algs}

#### Returns
[System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String')
