[英]Jetty HTTP Client Digest Auth
我正在尝试使用Jetty HTTP Client和Digest Auth进行身份验证。
我总是得到例外:
org.eclipse.jetty.client.HttpResponseException: HTTP protocol violation: Authentication challenge without WWW-Authenticate header
这是我的代码:
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);
出于测试目的,我使用http://httpbin.org/端点,但我也尝试了其他端点 - 所有都没有成功......
我错过了什么或做错了吗?
我相信此消息代表401
http状态以及您必须在请求中传递Authorization
标头的情况。
例如,当您尝试在没有令牌的情况下访问OAuth 2.0安全端点时,这是典型情况。 至少这是我面临的问题,与jetty http客户端有同样的错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.