We have searched and searched and still cannot seem to get a resolution to this issue. We have a REST web service and are trying to access it from our Android app. The web service URL work when accessed from a web browser or from the Advanced Rest Client extension in Chrome. Our URL looks like:
http://10.52.1.1:8080/GPService/Tenants(Name=DefaultTenant)/Companies(Fabrikam,%20Inc.)/Items(128%20SDRAM).JSON
And once this is typed into the browser we are prompted for credentials. After credentials are entered, the JSON result is returned.
In our Android app we are trying the following:
Authenticator.setDefault(new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("domain\\user", "password".toCharArray());
}
});
URL url = new URL(urlstring);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setDoOutput(false);
conn.setDoInput(true);
conn.setRequestMethod("GET");
conn.setConnectTimeout(60000);
InputStream istream = conn.getInputStream();
Any ideas what we are doing wrong? We tried different methods, similar to this Connecting to remote URL which requires authentication using Java and http://www.muneebahmad.com/index.php/archives/127 but with no success at all, we are constantly getting the 401 Unauthorized error.
As per a comment received: our service is using NTLM authentication.
Thanks for any help!