Created
December 6, 2013 15:47
-
-
Save deckerego/7826915 to your computer and use it in GitHub Desktop.
HTTP authentication should be performed according to RFC 2617. This specifies that:
- An "Authorization" name/value pair is added to the HTTP header
- The value of the Authorization header is a token consisting of the authorization scheme plus authentication token
- The authentication token is the value username:password, encoded as a base64 str…
This file contains hidden or 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
String authToken = new BASE64Encoder().encode(username + ":" + password); | |
URLConnection urlConnection = url.getUrl().openConnection(); | |
urlConnection.setDoOutput(true); | |
urlConnection.setConnectTimeout(5000); | |
urlConnection.setRequestProperty("Authorization", "Basic "+authToken); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment