public function createClient(Tenant $tenant, array $config = [], $class = null)
    {
        if (null === $class) {
            $class = $this->clientClass;
        }

        $pool = new TokenPool($tenant, $this->cache, $this->logger);
        $signer = new RequestSigner($pool);

        $stack = HandlerStack::create();
        $stack->before('http_errors', Middleware::signRequest($signer), 'signer');
        $stack->before('http_errors', Middleware::reauthenticate($signer), 'reauth');

        return new $class(array_merge($config, [
            'handler' => $stack,
            'token_pool' => $pool,
        ]));
    }