throw new ClientException(ex);
}
if (200 == response.getStatus()) {
ClientAccessToken token = fromMapToClientToken(map);
if (token == null) {
throw new OAuthServiceException(OAuthConstants.SERVER_ERROR);
} else {
return token;
}
} else if (400 == response.getStatus() && map.containsKey(OAuthConstants.ERROR_KEY)) {
OAuthError error = new OAuthError(map.get(OAuthConstants.ERROR_KEY),
map.get(OAuthConstants.ERROR_DESCRIPTION_KEY));
error.setErrorUri(map.get(OAuthConstants.ERROR_URI_KEY));
throw new OAuthServiceException(error);
}
throw new OAuthServiceException(OAuthConstants.SERVER_ERROR);
}