codeReg.setRedirectUri(redirectUri);
codeReg.setRequestedScope(requestedScope);
codeReg.setApprovedScope(approvedScope);
codeReg.setSubject(userSubject);
ServerAuthorizationCodeGrant grant = null;
try {
grant = ((AuthorizationCodeDataProvider)getDataProvider()).createCodeGrant(codeReg);
} catch (OAuthServiceException ex) {
return createErrorResponse(params, redirectUri, OAuthConstants.ACCESS_DENIED);
}
// return the code by appending it as a query parameter to the redirect URI
UriBuilder ub = getRedirectUriBuilder(params.getFirst(OAuthConstants.STATE), redirectUri);
ub.queryParam(OAuthConstants.AUTHORIZATION_CODE_VALUE, grant.getCode());
return Response.seeOther(ub.build()).build();
}