public ModelAndView build(final JEEContext context) throws Exception {
        val errorWithCallBack = (Boolean) context.getRequestAttribute(OAuth20Constants.ERROR_WITH_CALLBACK)
            .orElse(false);

        if (!errorWithCallBack) {
            return OAuth20Utils.produceUnauthorizedErrorView();
        }

        val error = context.getRequestAttribute(OAuth20Constants.ERROR)
            .orElseThrow()
            .toString();
        val errorDescription = context.getRequestAttribute(OAuth20Constants.ERROR_DESCRIPTION)
            .orElse(StringUtils.EMPTY)
            .toString();
        val clientId = context.getRequestParameter(OAuth20Constants.CLIENT_ID)
            .map(String::valueOf)
            .orElse(StringUtils.EMPTY);
        val redirectUri = context.getRequestParameter(OAuth20Constants.REDIRECT_URI)
            .map(String::valueOf)
            .orElse(StringUtils.EMPTY);

        val state = context.getRequestParameter(OAuth20Constants.STATE)
            .map(String::valueOf)
            .orElse(StringUtils.EMPTY);

        val params = new LinkedHashMap<String, String>();
        params.put(OAuth20Constants.ERROR, error);
        if (StringUtils.isNotBlank(errorDescription)) {
            params.put(OAuth20Constants.ERROR_DESCRIPTION, errorDescription);
        }
        if (StringUtils.isNotBlank(state)) {
            params.put(OAuth20Constants.STATE, state);
        }

        LOGGER.debug("Redirecting to URL [{}] with params [{}] for clientId [{}]", redirectUri, params.keySet(), clientId);
        return buildResponseModelAndView(context, servicesManager, clientId, redirectUri, params);
    }
Build string.

@param context the context
@return the view response
support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/web/response/callback/OAuth20InvalidAuthorizationResponseBuilder.java