protected AccessTokenRequestContext prepareAccessTokenRequestContext(
        final OAuth20AuthorizationRequest authzRequest,
        final OAuthRegisteredService registeredService,
        final JEEContext context,
        final Service service,
        final Authentication authentication) throws Exception {

        var payloadBuilder = AccessTokenRequestContext.builder();
        if (authzRequest.isSingleSignOnSessionRequired()) {
            val tgt = getConfigurationContext().fetchTicketGrantingTicketFrom(context);
            payloadBuilder = payloadBuilder.ticketGrantingTicket(tgt);
        }
        val requestParameterResolver = getConfigurationContext().getRequestParameterResolver();
        val redirectUri = requestParameterResolver
            .resolveRequestParameter(context, OAuth20Constants.REDIRECT_URI)
            .map(String::valueOf)
            .orElse(StringUtils.EMPTY);
        val grantType = context.getRequestParameter(OAuth20Constants.GRANT_TYPE)
            .map(String::valueOf)
            .orElseGet(OAuth20GrantTypes.AUTHORIZATION_CODE::getType)
            .toUpperCase(Locale.ENGLISH);
        val scopes = requestParameterResolver.resolveRequestScopes(context);
        val codeChallenge = context.getRequestParameter(OAuth20Constants.CODE_CHALLENGE)
            .map(String::valueOf).orElse(StringUtils.EMPTY);

        val challengeMethodsSupported = getConfigurationContext().getCasProperties().getAuthn().getOidc().getDiscovery().getCodeChallengeMethodsSupported();
        val codeChallengeMethod = context.getRequestParameter(OAuth20Constants.CODE_CHALLENGE_METHOD)
            .map(String::valueOf)
            .filter(challengeMethodsSupported::contains)
            .orElse(StringUtils.EMPTY)
            .toUpperCase(Locale.ENGLISH);

        val userProfile = OAuth20Utils.getAuthenticatedUserProfile(context, getConfigurationContext().getSessionStore());
        val claims = requestParameterResolver.resolveRequestClaims(context);
        val holder = payloadBuilder
            .service(service)
            .authentication(authentication)
            .registeredService(registeredService)
            .grantType(requestParameterResolver.resolveGrantType(context))
            .responseType(requestParameterResolver.resolveResponseType(context))
            .codeChallenge(codeChallenge)
            .codeChallengeMethod(codeChallengeMethod)
            .scopes(scopes)
            .clientId(authzRequest.getClientId())
            .redirectUri(redirectUri)
            .userProfile(userProfile)
            .claims(claims)
            .responseMode(requestParameterResolver.resolveResponseModeType(context))
            .build();
        context.getRequestParameters().keySet()
            .forEach(key -> context.getRequestParameter(key).ifPresent(value -> holder.getParameters().put(key, value)));
        LOGGER.debug("Building authorization response for grant type [{}] with scopes [{}] for client id [{}]",
            grantType, scopes, authzRequest.getClientId());
        return holder;
    }
Handle request post.

@param request  the request
@param response the response
@return the model and view
@throws Throwable the throwable
support/cas-server-support-oauth-core-api/src/main/java/org/apereo/cas/support/oauth/web/endpoints/OAuth20AuthorizeEndpointController.java