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"],