HttpURLConnection
클래스를 사용하여 Android 앱에서 HTTP 연결을 관리하고 있습니다. 문제는 일부 서버에서 인터넷 탐색기에서 작동하는 URL을 사용하는 코드 입니다. 기본 인증으로 연결을 초기화하지만이 서버는 다른 모드가 필요하다고 생각합니다.HttpURLConnection 인증 모드
curl_easy_setopt(pCurlHandle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
그러나이 안드로이드에 그런 일을하고에 방법이다 : 나는 libcurl에 다음과 같은 명령으로 작동 알아?
...
connection.setRequestProperty("Authorization", "Basic " + Base64.encode("username:password"));
...
내가 너무 Authenticator
으로 시도 :
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication()
{
return new PasswordAuthentication("username", "password".toCharArray());
}
});
을하지만 난 여전히 내 애플 리케이션에 401이 현재 내가 그렇게. 어떤 생각?