Skip to content

Instantly share code, notes, and snippets.

@radutoev
Created March 14, 2018 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save radutoev/c52e773fd7491448f8d7ae14af106fe2 to your computer and use it in GitHub Desktop.
Save radutoev/c52e773fd7491448f8d7ae14af106fe2 to your computer and use it in GitHub Desktop.
@Autowired
TokenString tokenString;
public String callB() {
RestTemplate restTemplate = new RestTemplate();
HttpHeaders headers = new HttpHeaders();
headers.set("Authorization", "bearer " + tokenString.getValue());
HttpEntity entity = new HttpEntity(headers);
ResponseEntity re = restTemplate.exchange(<SERVICE_B_ADDRESS>, HttpMethod.GET, entity, String.class);
return re.getStatusCode().equals(HttpStatus.OK) ? "ok" : "not ok";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment