title: .Net Core HttpClient Digest Authentication
body: <p>Working with the Mongo Atlas API in a .Net Core 3.1 application, but I cannot get <code>HttpClient</code> to handle the challenge from Digest Authentication.  </p>
  
  <p>The code sends the first request, gets a 401 response, and then doesn't resend with proper authentication. </p>
  
  <p>Below is the code I've been trying to get working</p>
  
  <pre class="lang-cs prettyprint-override"><code>var domain = "https://cloud.mongodb.com/";
  var credCache = new CredentialCache();
  credCache.Add(new Uri(domain),"Digest", new NetworkCredential(user,secret));
  var httpClient = new HttpClient( new HttpClientHandler { Credentials = credCache});
  var answer = await httpClient.GetAsync(new Uri($"{domain}api/atlas/v1.0/groups/{groupId}/databaseUsers"));
  </code></pre>
  
  <p>Here's the response I'm getting</p>
  
  <pre><code>StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
  {
    Date: Mon, 27 Jan 2020 21:03:14 GMT
    WWW-Authenticate: Digest realm="MMS Public API", domain="", nonce="generatedNonce", algorithm=MD5, qop="auth", stale=false
    Content-Type: application/json
    Content-Length: 106
  }
  </code></pre>
  
  <p>I've sent curl requests successully so I'm certain my user/secret/group are correct. </p>
  
  <p>Does anyone see something wrong with that code, or know what I can do to further debug this issue?</p>