I am trying to get authenticated using a Jetty HTTP Client and Digest Auth.
I always get the Exception:
org.eclipse.jetty.client.HttpResponseException: HTTP protocol violation: Authentication challenge without WWW-Authenticate header
Here is my Code:
HttpClient httpClient = new HttpClient();
httpClient.start();
String realm = "me@kennethreitz.com";
String user = "user";
String pass = "passwd";
URI uri =new URI("http://httpbin.org/digest-auth/auth/user/passwd/MD5");
AuthenticationStore a = httpClient.getAuthenticationStore();
a.addAuthentication(
new DigestAuthentication(uri, realm, user, pass));
ContentResponse response = httpClient
.newRequest(uri)
.send();
//.get(5, TimeUnit.SECONDS);
System.out.println(response);
For testing purposes i use a http://httpbin.org/ endpoint, but i also tried other endpoints - all unsuccessfully...
Am i missing something or doing wrong?