【发布时间】:2014-09-15 07:33:38
【问题描述】:
我无法让基本身份验证在 HTTP GET 上工作。 getCredentialsProvider 不存在,然后我环顾四周并尝试了 HttpBuilder 但它也不存在。我运行 Android Sdk 更新仍然没有运气。 我花了三个小时环顾四周,尝试了我找到的每一个,但总有一些不存在的部分。
HttpClient httpclient = new DefaultHttpClient();
String username = "User";
String password = "Pass";
Credentials credentials = new UsernamePasswordCredentials(username , password );
httpclient.getCredentialsProvider().setCredentials(AuthScope.ANY,credentials);
谢谢
【问题讨论】:
-
我不知道答案,但你不应该不使用基本认证。这是非常不安全的。任何设备都可以打破这一点。请改用摘要!