Use of basic Authentication for post URL

U

To mark all url in application authenticate, use of basic authentication could good option.

In Below example I used Username and Password to generate Authentication header .

 

String authentication = editusername.getText().toString().trim()+”:”+editpassword.getText().toString().trim();

String authHeader =Base64.encodeToString(authentication.getBytes(), Base64.NO_WRAP);

 

Use this “authHeader”  in every call of Url…like this,

httpPut.setHeader(“Authorization”, “Basic “+””+authHeader);

or

httpPost.addHeader(“Authorization”, “Basic “+””+authHeader);

About the author

dattatray.nande
By dattatray.nande

Category