protected ModelAndView buildCallbackUrlResponseType(final AccessTokenRequestContext tokenRequestContext,
                                                        final Ticket givenAccessToken, final Ticket givenRefreshToken,
                                                        final List<NameValuePair> parameters) throws Throwable {
        val attributes = tokenRequestContext.getAuthentication().getAttributes();
        
        val accessToken = resolveAccessToken(givenAccessToken);
        val paramsToBuild = new LinkedHashMap<String, String>();

        parameters.forEach(nvp -> paramsToBuild.put(nvp.getName(), nvp.getValue()));
        
        if (includeAccessTokenInResponse(tokenRequestContext) && accessToken.getExpiresIn() > 0) {
            val cipher = OAuth20JwtAccessTokenEncoder.toEncodableCipher(configurationContext,
                tokenRequestContext.getRegisteredService(), accessToken,
                tokenRequestContext.getService(), false);
            val encodedAccessToken = cipher.encode(accessToken.getId());
            paramsToBuild.put(OAuth20Constants.ACCESS_TOKEN, encodedAccessToken);
            paramsToBuild.put(OAuth20Constants.TOKEN_TYPE, OAuth20Constants.TOKEN_TYPE_BEARER);
            paramsToBuild.put(OAuth20Constants.EXPIRES_IN, String.valueOf(accessToken.getExpiresIn()));
        }

        if (givenRefreshToken != null) {
            val refreshToken = resolveRefreshToken(givenRefreshToken);
            paramsToBuild.put(OAuth20Constants.REFRESH_TOKEN, refreshToken.getId());
        }

        CollectionUtils.firstElement(attributes.get(OAuth20Constants.STATE))
            .ifPresent(state -> paramsToBuild.put(OAuth20Constants.STATE, state.toString()));
        CollectionUtils.firstElement(attributes.get(OAuth20Constants.NONCE))
            .ifPresent(nonce -> paramsToBuild.put(OAuth20Constants.NONCE, nonce.toString()));
        
        LOGGER.debug("Redirecting to URL [{}]", tokenRequestContext.getRedirectUri());
        val registeredService = OAuth20Utils.getRegisteredOAuthServiceByClientId(
            configurationContext.getServicesManager(), accessToken.getClientId());
        var responseMode = tokenRequestContext.getResponseMode();
        if (responseMode == null || responseMode == OAuth20ResponseModeTypes.NONE) {
            responseMode = OAuth20ResponseModeTypes.FRAGMENT;
        }
        return build(registeredService, responseMode, tokenRequestContext.getRedirectUri(), paramsToBuild);
    }
This is {@link OAuth20TokenAuthorizationResponseBuilder}.

@author Misagh Moayyed
@since 5.2.0
support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/web/response/callback/OAuth20TokenAuthorizationResponseBuilder.java