Skip to content

Instantly share code, notes, and snippets.

@jkuipers
Created May 21, 2012 20:50
Show Gist options
  • Save jkuipers/2764596 to your computer and use it in GitHub Desktop.
Save jkuipers/2764596 to your computer and use it in GitHub Desktop.
RestTemplate with basic or digest authentication configured
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);
@mythnc
Copy link

mythnc commented Feb 7, 2017

Thank you!
This is very helpful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment