protected OAuth20TokenGeneratedResult generateAccessTokenOAuthDeviceCodeResponseType(
        final AccessTokenRequestContext tokenRequestContext) throws Throwable {
        val deviceCode = tokenRequestContext.getDeviceCode();

        if (StringUtils.isNotBlank(deviceCode)) {
            val deviceCodeTicket = getDeviceTokenFromTicketRegistry(deviceCode);
            val deviceUserCode = getDeviceUserCodeFromRegistry(deviceCodeTicket);

            if (deviceUserCode.isUserCodeApproved()) {
                LOGGER.debug("Provided user code [{}] linked to device code [{}] is approved", deviceCodeTicket.getId(), deviceCode);
                ticketRegistry.deleteTicket(deviceCode);

                val deviceResult = AccessTokenRequestContext
                    .builder()
                    .service(tokenRequestContext.getService())
                    .authentication(tokenRequestContext.getAuthentication())
                    .registeredService(tokenRequestContext.getRegisteredService())
                    .ticketGrantingTicket(tokenRequestContext.getTicketGrantingTicket())
                    .grantType(tokenRequestContext.getGrantType())
                    .scopes(new LinkedHashSet<>())
                    .responseType(tokenRequestContext.getResponseType())
                    .generateRefreshToken(tokenRequestContext.getRegisteredService() != null && tokenRequestContext.isGenerateRefreshToken())
                    .build();

                val ticketPair = generateAccessTokenOAuthGrantTypes(deviceResult);
                return generateAccessTokenResult(deviceResult, ticketPair);
            }

            if (deviceCodeTicket.getLastTimeUsed() != null) {
                val interval = Beans.newDuration(casProperties.getAuthn().getOauth().getDeviceToken().getRefreshInterval()).toSeconds();
                val shouldSlowDown = deviceCodeTicket.getLastTimeUsed().plusSeconds(interval)
                    .isAfter(ZonedDateTime.now(ZoneOffset.UTC));
                if (shouldSlowDown) {
                    LOGGER.error("Request for user code approval is greater than the configured refresh interval of [{}] second(s)", interval);
                    throw new ThrottledOAuth20DeviceUserCodeApprovalException(deviceCodeTicket.getId());
                }
            }
            deviceCodeTicket.update();
            ticketRegistry.updateTicket(deviceCodeTicket);
            LOGGER.error("Provided user code [{}] linked to device code [{}] is NOT approved yet", deviceCodeTicket.getId(), deviceCode);
            throw new UnapprovedOAuth20DeviceUserCodeException(deviceCodeTicket.getId());
        }

        val deviceTokens = createDeviceTokensInTicketRegistry(tokenRequestContext);
        return OAuth20TokenGeneratedResult
            .builder()
            .responseType(tokenRequestContext.getResponseType())
            .registeredService(tokenRequestContext.getRegisteredService())
            .deviceCode(deviceTokens.deviceCode().getId())
            .userCode(deviceTokens.userCode().getId())
            .build();
    }
This is {@link OAuth20DefaultTokenGenerator}.

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