I want to make a request with an authentification on an android application with api level 4, HttpClient and httpGet.
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response;
String responseString = null;
try {
HttpGet httpGet = new HttpGet(uri);
httpGet.addHeader("referer","http://url.com");
response = httpclient.execute(httpGet);
StatusLine statusLine = response.getStatusLine();
if (statusLine.getStatusCode() == HttpStatus.SC_OK) {
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.getEntity().writeTo(out);
out.close();
responseString = out.toString();
} else {
response.getEntity().getContent().close();
}
} catch (Exception e) {
return null;
}
return responseString;
I test various solution it doesn't work !
maybe I'm doing it wrong !
On IOS it's not very secure but it work with : login:pass@url.com