gpt4 book ai didi

C# SSL 基本访问认证

转载 作者:太空狗 更新时间:2023-10-30 00:36:42 26 4
gpt4 key购买 nike

我想从第三方请求报告,他们需要通过 POST 进行“基本访问身份验证”:

Your client application must use Basic Access Authentication 
to send the user name and password.

有人能指出我正确的方向吗?

编辑:我确实看到了 this post但有两个答案,我不确定这是否是我需要做的,或者哪个是首选方法。

最佳答案

假设您使用 WebRequest,您将 CredentialCache 附加到您的请求:

        NetworkCredential nc = new NetworkCredential("user", "password");
CredentialCache cc = new CredentialCache();
cc.Add("www.site.com", 443, "Basic", nc);


WebRequest request = WebRequest.Create("https://www.site.com");
request.Credentials = cc;
request.PreAuthenticate = true;
request.Method = "POST";

// fill in other request properties here, like content

WebResponse respose = request.GetResponse();

关于C# SSL 基本访问认证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1127223/

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