AuthenticationHeaderValue 构造函数

定义

初始化 AuthenticationHeaderValue 类的新实例。

重载

AuthenticationHeaderValue(String)

初始化 AuthenticationHeaderValue 类的新实例。

AuthenticationHeaderValue(String, String)

初始化 AuthenticationHeaderValue 类的新实例。

AuthenticationHeaderValue(String)

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

初始化 AuthenticationHeaderValue 类的新实例。

public:
 AuthenticationHeaderValue(System::String ^ scheme);
public AuthenticationHeaderValue (string scheme);
new System.Net.Http.Headers.AuthenticationHeaderValue : string -> System.Net.Http.Headers.AuthenticationHeaderValue
Public Sub New (scheme As String)

参数

scheme
String

用于身份验证的方案。

注解

示例:

HttpClient client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(ACCESS_TOKEN);
Dim client = New HttpClient()
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(ACCESS_TOKEN)

将生成以下标头:

Authorization: ACCESS_TOKEN

适用于

AuthenticationHeaderValue(String, String)

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

初始化 AuthenticationHeaderValue 类的新实例。

public:
 AuthenticationHeaderValue(System::String ^ scheme, System::String ^ parameter);
public AuthenticationHeaderValue (string scheme, string parameter);
public AuthenticationHeaderValue (string scheme, string? parameter);
new System.Net.Http.Headers.AuthenticationHeaderValue : string * string -> System.Net.Http.Headers.AuthenticationHeaderValue
Public Sub New (scheme As String, parameter As String)

参数

scheme
String

用于身份验证的方案。

parameter
String

包含请求资源的用户代理的身份验证消息的凭证。

注解

示例:

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

将生成以下标头:

Authorization: Bearer ACCESS_TOKEN

适用于