hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pete Keyes <PKe...@starbucks.com>
Subject RE: Basic Authentification on httpclient 4.0.1
Date Mon, 02 Aug 2010 15:24:42 GMT
I'll try to help a bit...we use 3.1, but the high level answer here will likely be the same.
 Everyone else that answers will want a wire log - this will give the for-sure answer as to
why your code isn't sending the Basic Auth.

The most likely reason is that the "realm" you've associated the credentials with isn't actually
correct - you have used "www.example.com, 80" below.  I know that is just a filler and that
your real code isn't using that realm.

For an easy test change from a specific realm to the ANY_REALM and try your code.  If it works
then it is 100% because the realm you've provided isn't the correct value.


>-----Original Message-----
>From: Christian Blechert [mailto:blechert@ta-hameln.de]
>Sent: Monday, August 02, 2010 8:09 AM
>To: httpclient-users@hc.apache.org
>Subject: Basic Authentification on httpclient 4.0.1
>  Hey Guys.
>I'm using httpclient 4.0.1 to access a basic auth protected Website. But
>it works not really...
>My source code follows this example:
>DefaultHttpClient client = new DefaultHttpClient();
>UsernamePasswordCredentials creds = new
>UsernamePasswordCredentials("username", "password");
>AuthScope("www.example.com", 80), creds);
>BasicHttpContext localcontext = new BasicHttpContext();
>BasicScheme basicAuth = new BasicScheme();
>localcontext.setAttribute("preemptive-auth", basicAuth);
>client.addRequestInterceptor(new PreemptiveAuth(), 0);
>HttpGet httpget = new HttpGet("http://www.example.com/dosomething.html");
>HttpResponse response = client.execute(httpget);
>The code will executed. But the credentials will be not send.
>The class PreemptiveAuth can be found in the example.
>What is wrong? Any ideas?
>Thanks for your help. :-)
>Christian Blechert.
>To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>For additional commands, e-mail: httpclient-users-help@hc.apache.org

To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org

View raw message