Http client call while calling an api which is behind f5 and has NTLM authentication implemented iis server

80 Views Asked by At

I am trying to call an api with which has implemented NTLM authentication in the deployed iis server. This is giving proper response when tried from postman or in the browser, but this doesn't work when tried from code as mentioned below, code is in c# and i am using . netcore7 I know it is a three step process. The http client which I call is always giving me 401 in response.

Here is the sample code

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);
    }

When I check response, i have 401 and the challenge www-Authenticate of the second step and no Type3 message is passed.

How can we do this? Please help

I tried multiple ways to send the server response in the next request headers, but not able to generate proper Authorization header

0

There are 0 best solutions below