res.addCookie(new Cookie("tokenEndpoint", oauthParams.getTokenEndpoint()));
res.addCookie(new Cookie("redirectUri", oauthParams.getRedirectUri()));
res.addCookie(new Cookie("scope", oauthParams.getScope()));
res.addCookie(new Cookie("app", oauthParams.getApplication()));
OAuthClientRequest request = OAuthClientRequest
.authorizationLocation(oauthParams.getAuthzEndpoint())
.setClientId(oauthParams.getClientId())
.setRedirectURI(oauthParams.getRedirectUri())
.setResponseType(ResponseType.CODE.toString())
.setScope(oauthParams.getScope())
.buildQueryMessage();
return new ModelAndView(new RedirectView(request.getLocationUri()));
} catch (ApplicationException e) {
oauthParams.setErrorMessage(e.getMessage());
return new ModelAndView("get_authz");
}