0

I am using the following code to prepare a handler for HttpClient:

var uri = new Uri("URL");
 var credentialsCache = new CredentialCache();
 credentialsCache.Add(uri, "NTLM", new NetworkCredential("username", "password"));
 var handler = new HttpClientHandler() { Credentials = credentialsCache, PreAuthenticate = true };
 handler.ClientCertificateOptions = ClientCertificateOption.Manual;
 handler.ServerCertificateCustomValidationCallback =
 (httpRequestMessage, cert, cetChain, policyErrors) =>
 {
            return true;
 };
 ....
 new HttpClient(handler);

Is it possible to avoid using real username and password?

Thanks

Mark
  • 4,535
  • 7
  • 39
  • 76
  • 2
    Maybe I am misunderstanding your question, but it looks like you're asking if you can access a password-protected resource without a username and password... No, you wouldn't be able to do that. – Jonathan Feb 08 '22 at 00:28
  • Not 100% sure, but maybe [this helps](https://stackoverflow.com/questions/12212116/how-to-get-httpclient-to-pass-credentials-along-with-the-request)? – ProgrammingLlama Feb 08 '22 at 01:26

0 Answers0