我使用asynhttpClient基本認證Android的身份驗證方案NTLM不支持
http://loopj.com/android-async-http/
是裝置100j lib中。
下面是我的代碼:
usernameRandomPassword =用戶名+「: 「+密碼;下面
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) {
}
但我總是在控制檯401接收的日誌不支持
認證方案NTLM。
無法迴應任何這些挑戰:{= NTLM WWW身份驗證:NTLM,洽談= WWW身份驗證:協商}
的憑據是正確的我查了直接的聯繫。
我已經花了這一整天,任何人都可以幫助我嗎? 如果你分享一些例子,它會非常有幫助。
在此先感謝..
鏈接不起作用。另外我得到'getAuthSchemes()'是不確定的HttpClient。 – Darpan
我刪除了httpclient.getAuthSchemes()。register(「ntlm」,new NTLMSchemeFactory());它工作正常。所以我不需要添加庫或NTLMSchemeFactory類 – Hamid
@Hamid它將如何響應NTLM身份驗證挑戰呢?你確定你正在做一個不需要NTLM的web服務嗎? – Sufian