Http 客户端调用,同时调用 f5 后面的 api 并实现了 NTLM 身份验证 iis 服务器

问题描述 投票:0回答:0

我正在尝试调用已在部署的 iis 服务器中实现 NTLM 身份验证的 api。 当从邮递员或浏览器中尝试时,这会给出正确的响应,但是当从下面提到的代码中尝试时,这不起作用,代码在 c# 中,我正在使用 .网核7 我知道这是一个三步过程。我调用的 http 客户端总是给我 401 作为响应。

这里是示例代码

var uri = new uri(https: //     xyz.xyz.org/api/controller 

    using HttpclientHandler handler = new() {
        Credentials = new NetworkCredential(username, password, domain),
            usecookies = true,
            CookiesContainer = new CookiesContainer(),
            PreAuthenticate = true
    }; using Httpclient client = new(handler) {
        var response = await client.GetAsync(uri);
    }

当我检查响应时,我有 401 和第二步的挑战 www-Authenticate 并且没有传递 Type3 消息。

我们怎样才能做到这一点?请帮助

我尝试了多种方法在下一个请求标头中发送服务器响应,但无法生成正确的授权标头

asp.net-core httpclient dotnet-httpclient ntlm ntlm-authentication
© www.soinside.com 2019 - 2024. All rights reserved.