@PostMapping(path = OAuth20Constants.BASE_OAUTH20_URL + '/' + OAuth20Constants.DEVICE_AUTHZ_URL)
    @Operation(summary = "Handle device code approval request")
    public ModelAndView handlePostRequest(final HttpServletRequest request, final HttpServletResponse response) {
        val userCode = request.getParameter(PARAMETER_USER_CODE);
        val codeNotfound = getModelAndViewForFailure("codenotfound");
        if (StringUtils.isBlank(userCode)) {
            return codeNotfound;
        }
        try {
            val factory = (OAuth20DeviceUserCodeFactory) getConfigurationContext().getTicketFactory().get(OAuth20DeviceUserCode.class);
            val codeId = factory.normalizeUserCode(userCode);
            val deviceUserCode = getConfigurationContext().getTicketRegistry().getTicket(codeId, OAuth20DeviceUserCode.class);
            if (deviceUserCode.isUserCodeApproved()) {
                return getModelAndViewForFailure("codeapproved");
            }
            deviceUserCode.setUserCodeApproved(true);
            val updatedDeviceUserCode = getConfigurationContext().getTicketRegistry().updateTicket(deviceUserCode);
            return new ModelAndView(OAuth20Constants.DEVICE_CODE_APPROVED_VIEW,
                Map.of("code", updatedDeviceUserCode.getId()), HttpStatus.OK);
        } catch (final Exception e) {
            LoggingUtils.warn(LOGGER, e);
            return codeNotfound;
        }
    }
Handle request internal model and view.

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