I am using asynhttpClient for basic authentication
http://loopj.com/android-async-http/
i.e. looj lib ..
below is my code:
usernameRandomPassword = username + ":" + password;
Log.d("username=",usernameRandomPassword);
Log.d("url=",url);
String authorization = "Basic " + Base64.encodeToString(usernameRandomPassword.getBytes("UTF-8"), Base64.NO_WRAP);
httpClient.addHeader("Authorization",authorization);
httpClient.addHeader("Content-type", "application/json");
httpClient.setTimeout(20000);
httpClient.get( url, new AsyncHttpResponseHandler() {
@Override
public void onStart() {
System.out.println("on satrt");
super.onStart();
}
@Override
public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
System.out.println("on onSuccess statusCode="+statusCode);
toastmessgae("onSuccess status code="+statusCode);
super.onSuccess(statusCode, headers, responseBody);
}
@Override
public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
System.out.println("on onFailure="+statusCode);
toastmessgae("onFailure status code="+statusCode);
super.onFailure(statusCode, headers, responseBody, error);
}
@Override
public void onFinish() {
System.out.println("on onFinish");
super.onFinish();
}
});
} catch (UnsupportedEncodingException e) {
}
but I always get in console 401, below are the logs
The ntlm authentication scheme is not supported.
Unable to answer any of these problems: {ntlm = WWW-Authenticate: NTLM, negotiate = WWW-Authenticate: Negotiate}
The credentials are correct, I checked the direct link.
I have already spent the whole day on this, can someone help me? If you share some example, it will be really useful.
Thanks in advance.
morya source
share