Skip to content

Instantly share code, notes, and snippets.

@odrotbohm
Created April 13, 2012 08:59
Show Gist options
  • Save odrotbohm/2375222 to your computer and use it in GitHub Desktop.
Save odrotbohm/2375222 to your computer and use it in GitHub Desktop.
Using RestTempalte with Basic authentication
HttpClient client = new HttpClient();
UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("your_user","your_password");
client.getState().setCredentials(new AuthScope("thehost", 9090, AuthScope.ANY_REALM), credentials);
ClientHttpRequestFactory requestFactory= new HttpComponentsClientHttpRequestFactory(client);
RestOperations operations new RestTemplate(requestFactory);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment