use of wooteco.prolog.login.excetpion.GithubConnectionException in project prolog by woowacourse.
the class GithubClient method getGithubProfileFromGithub.
public GithubProfileResponse getGithubProfileFromGithub(String accessToken) {
HttpHeaders headers = new HttpHeaders();
headers.add("Authorization", "token " + accessToken);
HttpEntity httpEntity = new HttpEntity<>(headers);
RestTemplate restTemplate = new RestTemplate();
try {
return restTemplate.exchange(profileUrl, HttpMethod.GET, httpEntity, GithubProfileResponse.class).getBody();
} catch (HttpClientErrorException e) {
throw new GithubConnectionException();
}
}
Aggregations