I am using an HttpsUrlConnection
with Basic Authentication by using an Authenticator
and setting a default Authenticator
object like t
I wish I knew the proper answer to this, because I ran into the exact same problem. I couldn't find a way to handle the authentication error, or even get notified about it.
I ended up having to use HttpClient
instead.
HttpClient client = new DefaultHttpClient();
HttpGet get = new HttpGet(loginUrl);
String authString = (userName+":"+password);
get.addHeader("Authorization", "Basic " +
Base64.encodeToString(authString.getBytes(),Base64.NO_WRAP));
HttpResponse response = client.execute(get);
BufferedReader r = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));