Janusz
Janusz

Reputation: 189594

How to authorize to a web server with android and the org.apache.http classes?

I'm trying to authenticate to a web server from an android class with the org.apache.http.HttpClient.

How can I do this? The code for my connection is:

HttpClient httpClient = new DefaultHttpClient();
HttpGet httpGet = new HttpGet("url");

HttpResponse response = null;

try {
    response = httpClient.execute(httpGet);
} catch (ClientProtocolException e) {
   ...
} catch (IOException e) {
   ...
}
Log.i("httptest", response.getStatusLine().toString());
HttpEntity entity = response.getEntity();

Edit

I want to do a basic authentication with username and password

Upvotes: 0

Views: 440

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007624

Documentation for HttpClient can be found at the HttpClient site.

You don't say what sort of authentication you are trying to use, so it is impossible to give you concrete answers. Here are some tutorials that may match your needs.

Upvotes: 1

Related Questions