public static function retry(&$api, $config)
    {
        $retryRequest = function (
            $retries, $request, $response, $error
        ) use ($api, $config) {
            // Refresh token middleware
            if ($response and $response->getStatusCode() == 401) {
                return self::refreshToken($api, $config, $retries);
            }

            // Don't retry on other requests.
            return false;
        };

        return Middleware::retry($retryRequest);
    }