Search code examples
httpapache-httpclient-4.xhttp-authenticationbasic-authenticationhttp-digest

Is client implementation for HTTP basic and digest authentication the same?


According to Apache's guide to HTTP authentication. Both basic and digest authentication requires a UsernamePasswordCredentials instance.

My question is can I use the same client implementation for server authentication for both basic and digest following this example?


Solution

  • Yes, you can and you should. HttpClient is capable of employing different auth schemes in the course of a single request execution (for instance using Basic to authenticate with the proxy and NTLM to authenticate with the origin server)