hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kash_meu <muhammad.kashif.na...@gmail.com>
Subject Re: BasicAuthentication using HttpClient 4.0
Date Sat, 26 Sep 2009 10:20:43 GMT

Hi Tobi,

Thanks for your help. The link you told is useful for HttpClient 3.1 but
there is a lot of difference between 4.0 and 3.1.

I solved my problem. This is the solution.

HttpGet httpGet = new HttpGet(url);
UsernamePasswordCredentials credentials = new
UsernamePasswordCredentials(username, password);
		BasicScheme scheme = new BasicScheme();
		Header authorizationHeader = scheme.authenticate(credentials,
httpRequest);
                
                httpGet.addHeader(authorizationHeader);


Regards,
Kashif



Tobias N. Sasse wrote:
> 
> kash_meu schrieb:
>> Thanks. I am not getting any error messages. But the output is not right.
>> When I paste http://abcdef.4y3hsw@hostname.com/abc.php in the browser, I
>> get
>> the right output. But on running the client, the output is not what I am
>> expectin
> 
> Hi, I have no idea of authentication myself, but you should probably 
> have a look at this tutorial:
> 
> http://hc.apache.org/httpclient-3.x/authentication.html
> 
> I know this is for version-3 but perhaps you get an idea how it could 
> work. I guess the problem is that providing the username and password in 
> the URL string is not the way httpclient is triggert to provide 
> authentication to the server?
> 
> Regards,
>     Tobi
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/BasicAuthentication-using-HttpClient-4.0-tp25578027p25624006.html
Sent from the HttpClient-User mailing list archive at Nabble.com.


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


Mime
View raw message