.setRedirectURI(oauthParams.getRedirectUri())
.setCode(oauthParams.getAuthzCode())
.setGrantType(GrantType.AUTHORIZATION_CODE)
.buildQueryMessage();
OAuthClient client = new OAuthClient(new URLConnectionClient());
String app = Utils.findCookieValue(req, "app");
OAuthAccessTokenResponse oauthResponse = null;
Class<? extends OAuthAccessTokenResponse> cl = OAuthJSONAccessTokenResponse.class;
if (Utils.FACEBOOK.equals(app)) {
cl = GitHubTokenResponse.class;
} else if (Utils.GITHUB.equals(app)) {
cl = GitHubTokenResponse.class;
}
oauthResponse = client.accessToken(request, cl);
oauthParams.setAccessToken(oauthResponse.getAccessToken());
oauthParams.setExpiresIn(oauthResponse.getExpiresIn());
oauthParams.setRefreshToken(Utils.isIssued(oauthResponse.getRefreshToken()));