Edit

Share via


AuthenticationHeaderValue Constructors

Definition

Initializes a new instance of the AuthenticationHeaderValue class.

Overloads

AuthenticationHeaderValue(String)

Initializes a new instance of the AuthenticationHeaderValue class.

AuthenticationHeaderValue(String, String)

Initializes a new instance of the AuthenticationHeaderValue class.

AuthenticationHeaderValue(String)

Source:
AuthenticationHeaderValue.cs
Source:
AuthenticationHeaderValue.cs
Source:
AuthenticationHeaderValue.cs
Source:
AuthenticationHeaderValue.cs

Initializes a new instance of the AuthenticationHeaderValue class.

C#
public AuthenticationHeaderValue(string scheme);

Parameters

scheme
String

The scheme to use for authorization.

Remarks

Example:

C#
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(ACCESS_TOKEN);

Will produce the following header:

txt
Authorization: ACCESS_TOKEN

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

AuthenticationHeaderValue(String, String)

Source:
AuthenticationHeaderValue.cs
Source:
AuthenticationHeaderValue.cs
Source:
AuthenticationHeaderValue.cs
Source:
AuthenticationHeaderValue.cs

Initializes a new instance of the AuthenticationHeaderValue class.

C#
public AuthenticationHeaderValue(string scheme, string parameter);
C#
public AuthenticationHeaderValue(string scheme, string? parameter);

Parameters

scheme
String

The scheme to use for authorization.

parameter
String

The credentials containing the authentication information of the user agent for the resource being requested.

Remarks

Example:

C#
HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", ACCESS_TOKEN);

Will produce the following header:

txt
Authorization: Bearer ACCESS_TOKEN

Applies to

.NET 10 and other versions
Product Versions
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9, 10
.NET Framework 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0