Created
September 16, 2012 08:58
-
-
Save DevJonny/3731666 to your computer and use it in GitHub Desktop.
Android how to get HTTP 401 response
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
final HttpGet loginDetailsGet = new HttpGet("{your URL to pass login details to}"); | |
loginDetailsGet.addHeader("accept", "application/json"); | |
final HttpParams httpParameters = new BasicHttpParams(); | |
HttpConnectionParams.setConnectionTimeout(httpParameters, 5 * 1000); | |
final Credentials credentials = new UsernamePasswordCredentials(username, password); | |
final DefaultHttpClient defaultHttpClient = new DefaultHttpClient(httpParameters); | |
defaultHttpClient.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT), credentials); | |
final HttpResponse serverResponse = defaultHttpClient.execute(loginDetailsGet); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment