OAuth2ProfileContainer profileContainer = request.getResource().getService().getProject()
.getOAuth2ProfileContainer();
if (O_AUTH_2_0.toString().equals(request.getAuthType())) {
OAuth2Profile profile = profileContainer.getProfileByName(((AbstractHttpRequest) request).getSelectedAuthProfile());
if (profile == null || StringUtils.isNullOrEmpty(profile.getAccessToken())) {
return;
}
OAuth2ClientFacade oAuth2Client = getOAuth2ClientFacade();
if (accessTokenIsExpired(profile)) {
if (profile.shouldReloadAccessTokenAutomatically()) {
reloadAccessToken(profile, oAuth2Client);
} else {
profile.setAccessTokenStatus(OAuth2Profile.AccessTokenStatus.EXPIRED);
}
}
oAuth2Client.applyAccessToken(profile, httpMethod, request.getRequestContent());
}
}