From 907f4cb6fb46d3cff2e84f3bba172079305c188c Mon Sep 17 00:00:00 2001 From: Bruno MATEU Date: Sat, 17 Jun 2023 02:31:39 +0200 Subject: [PATCH] client.py token login --- prometheuspvesd/client.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/prometheuspvesd/client.py b/prometheuspvesd/client.py index 4d7c862..e20e0ed 100644 --- a/prometheuspvesd/client.py +++ b/prometheuspvesd/client.py @@ -44,6 +44,21 @@ class ProxmoxClient: self.config.config["pve"]["server"], self.config.config["pve"]["user"] ) ) + + if self.config.config["pve"]["token_name"]: + if !self.config.config["pve"]["token_value"]: + self.logger.error("Token name require token value to be set ! Fallback to password authentification") + + self.logger.debug("Using token login") + return ProxmoxAPI( + self.config.config["pve"]["server"], + user=self.config.config["pve"]["user"], + token_name=self.config.config["pve"]["token_name"], + token_value=self.config.config["pve"]["token_value"], + verify_ssl=to_bool(self.config.config["pve"]["verify_ssl"]), + timeout=self.config.config["pve"]["auth_timeout"] + ) + return ProxmoxAPI( self.config.config["pve"]["server"], user=self.config.config["pve"]["user"],