kash_meu wrote:
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



While this certainly does the trick for BASIC authentication, more complex schemes will not work that way.

This is the recommended way of handling authentication with HttpClient 4.0:

http://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk/httpclient/src/examples/org/apache/http/examples/client/ClientAuthentication.java
http://hc.apache.org/httpcomponents-client/tutorial/html/authentication.html

Oleg


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://[email protected]/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: [email protected]
For additional commands, e-mail: [email protected]






---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to