protected function getCachedIdentityService(Cache $cache, array $options): CachedIdentityService
   {
      if (!isset($options['authUrl'])) {
        throw new \InvalidArgumentException("'authUrl' is a required option");
      }

      $stack = HandlerStack::create();

      if (!empty($options['debugLog'])
            && !empty($options['logger'])
            && !empty($options['messageFormatter'])
      ) {
         $stack->push(GuzzleMiddleware::log($options['logger'], $options['messageFormatter']));
      }

      $clientOptions = [
         'base_uri' => Utils::normalizeUrl($options['authUrl']),
         'handler'  => $stack,
      ];

      if (isset($options['requestOptions'])) {
         $clientOptions = array_merge($options['requestOptions'], $clientOptions);
      }

      $service = CachedIdentityService::factory(new Client($clientOptions));
      $service->setCache($cache);

      return $service;
    }