Error “HTTP/1.1 401 Unauthorized” with basic authentication in android - EWS 2010

依然范特西╮ 提交于 2019-11-29 09:07:28

I was struggling with Android HTTP basic last week. I have tried maybe 3 or 4 different ways of doing it and always I found some problem. Right now the only way I managed to make it work was the simplest way.

 UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(user, pass);
 Header header = new BasicScheme().authenticate(credentials, mHttpRequest);
 mHttpRequest.addHeader(header);

That worked for me with AndroidHttpClient.

Edit:

This is my full source code

https://gist.github.com/2642692

It's based on http://lukencode.com/2010/04/27/calling-web-services-in-android-using-httpclient/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!