Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do HTTP authentication in android?

I am checking out the class org.apache.http.auth. Any more reference or example if anyone has?

like image 358
Bohemian Avatar asked Dec 28 '09 07:12

Bohemian


People also ask

What is HTTP authentication?

The HTTP Authorization request header can be used to provide credentials that authenticate a user agent with a server, allowing access to a protected resource. The Authorization header is usually, but not always, sent after the user agent first attempts to request a protected resource without credentials.


1 Answers

For me, it worked,

final String basicAuth = "Basic " + Base64.encodeToString("user:password".getBytes(), Base64.NO_WRAP); 

Apache HttpCLient:

request.setHeader("Authorization", basicAuth); 

HttpUrlConnection:

connection.setRequestProperty ("Authorization", basicAuth); 
like image 109
cesards Avatar answered Sep 22 '22 13:09

cesards