gpt4 book ai didi

c# - 无法设置 AuthenticationHeaderValue

转载 作者:行者123 更新时间:2023-11-30 16:59:57 27 4
gpt4 key购买 nike

我可以尝试设置一个仅用于测试目的的身份验证值。
我没有使用基本身份验证,而只是一个字符串

VC.Request.Headers.Authorization = new AuthenticationHeaderValue("Secret Password");

它给了我这个错误,让我扯掉了我的头发:

The format of value 'Secret Password' is invalid.

同样,我不想使用基本身份验证,我不知道出了什么问题,求助?

最佳答案

类是"documented"作为:

Represents authentication information in Authorization, ProxyAuthorization, WWW-Authneticate[sic], and Proxy-Authenticate header values.

通过使用一个参数调用构造函数,您将使用“Secret Password”作为 scheme,它只能包含标记(即没有空格)。参见 RFC 2617用于规范。

您可能想调用 other constructor overload :

new AuthenticationHeaderValue("MySuperAuthScheme", "Secret Password");

关于c# - 无法设置 AuthenticationHeaderValue,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22973616/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com