Issue #2721 new

Add a www-authenticate header to our response (BB-1692)

Shuji Watanabe
created an issue

Authentication failed. Java 1.6 httpcore-4.1.jar * httpclient-4.1.1.jar

Server require an authentication and return 401 status code. But server dont tell client to which authentication scheme is needed.

Sample Code {{{

!java

DefaultHttpClient httpclient = new DefaultHttpClient(); try { HttpGet httpget = new HttpGet("https://api.bitbucket.org/1.0/repositories/shuji.w6e/receipt-box/issues/"); httpclient.getCredentialsProvider().setCredentials(new AuthScope("api.bitbucket.org", 443), new UsernamePasswordCredentials("shuji.w6e", "**")); HttpResponse response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); System.out.println(response.getStatusLine()); if (entity != null) { System.out.println("Response content length: " + entity.getContentLength()); } EntityUtils.consume(entity); } finally { httpclient.getConnectionManager().shutdown(); } }}} Server response is not contains "WWW-Authenticate" header. Please append a header suche as "WWW-Authenticate: Basic realm="Authentication required".