protected function validateTokenScopes(array $scopes)
    {
        $scopes = array_map(function ($scope) {
            return (string) $scope;
        }, $scopes);

        $registeredScopes = $this->scopeService->getAll();

        $registeredScopes = array_map(function ($scope) {
            return (string) $scope;
        }, $registeredScopes);

        $diff = array_diff($scopes, $registeredScopes);

        if (count($diff) > 0) {
            throw OAuth2Exception::invalidScope(sprintf(
                'Some scope(s) do not exist: %s',
                implode(', ', $diff)
            ));
        }
    }