if (accessToken != null) {
final String accessTokenParameterKey = this.getAccessTokenParameterKey();
OAuthClientRequest clientReq = new OAuthBearerClientRequest(getUserResourceUri()) {
@Override
public OAuthBearerClientRequest setAccessToken(String accessToken) {
this.parameters.put(accessTokenParameterKey, accessToken);
return this;
}
}
.setAccessToken(accessToken)
.buildQueryMessage();
// needed for LinkedIn
clientReq.setHeader("x-li-format", "json");
logger.log(Level.INFO, "User info request: {0}", clientReq.getLocationUri());
OAuthClient oAuthClient = new OAuthClient(new URLConnectionClient());
userResponse = oAuthClient.resource(clientReq, "GET", OAuthResourceResponse.class);
logger.log(Level.INFO, "User info response: {0}", userResponse);