HttpRequestMessage Authentication and Digest

Is there a built-in function for linking digest authentication with HttpRequestMessage in winrt? Or do I need to use another class to complete this task?

Thanks.

+4
source share
1 answer

I am using HttpClient to post an HttpRequest. The HttpClient constructor accepts an HttpClientHandler , which accepts an instance of CredentialCache as the Credentials property. A CredentialCache should work with digest authentication.

The code should look like this:

 var credCache = new CredentialCache(); credCache.Add(new Uri("http://.com/"),"Digest", new NetworkCredential(UserName,SecurelyStoredPassword,Domain)); var httpClient = new HttpClient( new HttpClientHandler { Credentials = credCache}); var answer = httpClient.GetAsync(new Uri("http://request.Uri")); 
+11
source

Source: https://habr.com/ru/post/1413234/


All Articles