class ClientCredentialsGrantTypeHandler extends GrantTypeHandler {

    public AccessToken handle(OAuth2Request request, ClientRegistration clientRegistration,
            OAuth2ProviderSettings providerSettings) throws InvalidRequestException, ServerException,
            UnauthorizedClientException, InvalidScopeException, NotFoundException, InvalidClientException {

        for (final ClientCredentialsRequestValidator requestValidator : requestValidators) {
            requestValidator.validateRequest(request, clientRegistration);
        }

        final Set<String> scope = Utils.splitScope(request.<String>getParameter(SCOPE));
        final Set<String> validatedScope = providerSettings.validateAccessTokenScope(clientRegistration, scope,
                request);
        final String validatedClaims = providerSettings.validateRequestedClaims(
                (String) request.getParameter(OAuth2Constants.Custom.CLAIMS));
        final String grantType = request.getParameter(GRANT_TYPE);

        final AccessToken accessToken = tokenStore.createAccessToken(grantType, BEARER, null,
                clientRegistration.getClientId(), clientRegistration.getClientId(), null, validatedScope,
                null, null, validatedClaims, request);

        providerSettings.additionalDataToReturnFromTokenEndpoint(accessToken, request);

        if (validatedScope != null && !validatedScope.isEmpty()) {
            accessToken.addExtraData(SCOPE, Utils.joinScope(validatedScope));
        }

        tokenStore.updateAccessToken(accessToken);

        return accessToken;

    }

    @Inject public  ClientCredentialsGrantTypeHandler(ClientAuthenticator clientAuthenticator,
            List<ClientCredentialsRequestValidator> requestValidators, TokenStore tokenStore,
            OAuth2UrisFactory urisFactory,OAuth2ProviderSettingsFactory providerSettingsFactory);

}