Created
May 21, 2012 20:50
-
-
Save jkuipers/2764596 to your computer and use it in GitHub Desktop.
RestTemplate with basic or digest authentication configured
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
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory(); | |
DefaultHttpClient client = (DefaultHttpClient) factory.getHttpClient(); | |
client.getCredentialsProvider().setCredentials( | |
new AuthScope(hostName, portNumber), | |
new UsernamePasswordCredentials(username, password)); | |
RestTemplate restTemplate = new RestTemplate(factory); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!
This is very helpful!