HttpRequestMessage and Digest Authentication
Asked Answered
L

1

9

Is there any built-in function to associate a digest authentication with an HttpRequestMessage in winrt ? Or do I have to use an other class in order to perfom this task ?

Thanks.

Lentamente answered 18/5, 2012 at 18:51 Comment(0)
U
17

I'm using the HttpClient for an HttpRequest Message. The HttpClient constructor accepts a HttpClientHandler, which accepts as Credentials property an instance of CredentialCache. A CredentialCache should be able to work with digest authentication.

Code should be like:

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"));
Uterus answered 21/5, 2012 at 11:46 Comment(1)
Is there a way to do this per-request instead of for the entire HttpClient?Tung

© 2022 - 2024 — McMap. All rights reserved.