use of org.eclipse.che.api.core.ConflictException in project che by eclipse.
the class RemoteOAuthTokenProvider method getToken.
/** {@inheritDoc} */
@Override
public OAuthToken getToken(String oauthProviderName, String userId) throws IOException {
if (userId.isEmpty()) {
return null;
}
try {
UriBuilder ub = UriBuilder.fromUri(apiEndpoint).path(OAuthAuthenticationService.class).path(OAuthAuthenticationService.class, "token").queryParam("oauth_provider", oauthProviderName);
Link getTokenLink = DtoFactory.newDto(Link.class).withHref(ub.build().toString()).withMethod("GET");
return httpJsonRequestFactory.fromLink(getTokenLink).request().asDto(OAuthToken.class);
} catch (NotFoundException ne) {
LOG.warn("Token not found for user {}", userId);
return null;
} catch (ServerException | UnauthorizedException | ForbiddenException | ConflictException | BadRequestException e) {
LOG.warn("Exception on token retrieval, message : {}", e.getLocalizedMessage());
return null;
}
}
Aggregations