Hi,
I'm trying to connect to a site using digest authentication but it continuously gives "401 - Unauthorized" even the password is correct. Here's the sample code I'm using:
Uri uri = new Uri(apiUrl);
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(uri);
CredentialCache credCache = new CredentialCache();
credCache.Add(uri, "Digest", new NetworkCredential(username, password));
// Get the response.
using (HttpWebResponse res = (HttpWebResponse)req.GetResponse())
{
StreamReader sr = new StreamReader(res.GetResponseStream());
Console.WriteLine(sr.ReadToEnd());
}
This is the server header I got:
Server: Apache/2.2.13 (FreeBSD) mod_ssl/2.2.14 OpenSSL/0.9.8e DAV/2
mod_wsgi/2.8 Python/2.5.4 PHP/5.2.12 with Suhosin-Patch
Do you have any ideas on the problem? Thanks.
...
Go to the complete details ...