title: .NET 5 HttpClient Digest Authentication
body: <p>I'm trying to use <code>HttpClient</code> to do digest authentication in .NET 5 to work with mongoDB Atlas. The workaround suggested in <a href="https://stackoverflow.com/questions/59939357/net-core-httpclient-digest-authentication">.Net Core HttpClient Digest Authentication</a> no longer works for .NET 5.</p>
  <p>for example, this code</p>
  <pre><code>AppContext.SetSwitch(&quot;System.Net.Http.UseSocketsHttpHandler&quot;, false);
  var httpClient = new HttpClient(
              new HttpClientHandler
              {
                  Credentials =
                      new NetworkCredential(
                          userName,
                          password)
              });
  var domain = &quot;https://cloud.mongodb.com/&quot;;
  var response = httpClient.GetAsync(new Uri($&quot;{domain}api/atlas/v1.0/groups/{groupId}&quot;)).Result;
          
  </code></pre>
  <p>return 200 ok with the correct data when the target framework is .net core 3.1</p>
  <p>but  when the target framework is .NET 5 http client don't handle the digest flow behind the scenes and returns</p>
  <pre><code>StatusCode: 401, ReasonPhrase: 'Unauthorized', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
  {
    WWW-Authenticate: Digest realm=&quot;MMS Public API&quot;, domain=&quot;&quot;, nonce=&quot;&quot;generatedNonce&quot;&quot;, algorithm=MD5, qop=&quot;auth&quot;, stale=false
    x-envoy-upstream-service-time: 2
    Date: Sun, 17 Jan 2021 13:37:12 GMT
    Server: envoy
    Content-Type: application/json
    Content-Length: 106
  } 
  </code></pre>
  <p>does anyone know if I have any alternative besides implementing the digest flow by myself?</p>