use of org.apache.oltu.oauth2.client.OAuthClient in project structr by structr.
the class StructrOAuthClient method getAccessTokenResponse.
private OAuthAccessTokenResponse getAccessTokenResponse(final HttpServletRequest request) {
if (tokenResponse != null) {
return tokenResponse;
}
try {
String code = getCode(request);
if (code == null) {
logger.error("Could not get code from request, cancelling authorization process");
return null;
}
OAuthClientRequest clientReq = OAuthClientRequest.tokenLocation(tokenLocation).setGrantType(getGrantType()).setClientId(clientId).setClientSecret(clientSecret).setRedirectURI(getAbsoluteUrl(request, redirectUri)).setCode(getCode(request)).buildBodyMessage();
logger.info("Request body: {}", clientReq.getBody());
OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
tokenResponse = oAuthClient.accessToken(clientReq, tokenResponseClass);
logger.info("Access token response: {}", tokenResponse.getBody());
return tokenResponse;
} catch (Throwable t) {
logger.error("Could not get access token response", t);
}
return null;
}
Aggregations