parameter /user is deprecated
New versions of zabbix (at least in my case of 6.0) do not accept user parameter in login, it's now username
Hi @ghormoon
Thank you for reporting this. Is it the only change you've hit with new Zabbix version?
In case you already have a fix, you can consider a pull request. Contributions are very welcome.
Cheers
Jan
my temporary fix is to change 'user' to 'username' here, https://github.com/erigones/zabbix-api/blob/2474ab1d1ddb46c26eea70671b3a599b836d42da/zabbix_api.py#L330
but i don't know which version started that change (i'm on 6.0.x) so i didn't do any handling for older ones
https://www.zabbix.com/documentation/5.4/en/manual/api/changes_5.2_-_5.4 https://support.zabbix.com/browse/ZBXNEXT-6474 https://support.zabbix.com/browse/ZBXNEXT-6148 it was changed since 5.2 version.
it was changed in 5.4 based on that docs. Here is a patch, i didn't want to fork for such simple change, you can put it in file and git am file
do a quick test please, i'm running another fork, but i thought i should respond here too :)
From 22bd0a695259e1f7d385ce868d13d0df3bcff348 Mon Sep 17 00:00:00 2001
From: "[email protected]" <ghormoon@localhost>
Date: Wed, 5 Oct 2022 23:38:59 +0200
Subject: [PATCH] fix login for zabbix >=5.4
---
zabbix_api.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/zabbix_api.py b/zabbix_api.py
index d8dd8f7..bc6bada 100644
--- a/zabbix_api.py
+++ b/zabbix_api.py
@@ -327,7 +327,10 @@ class ZabbixAPI(object):
# Don't print the raw password
hashed_pw_string = 'md5(%s)' % md5(password.encode('utf-8')).hexdigest()
self.debug('Trying to login with %r:%r', user, hashed_pw_string)
- obj = self.json_obj('user.login', params={'user': user, 'password': password}, auth=False)
+ if self.api_version() >= '5.4':
+ obj = self.json_obj('user.login', params={'username': user, 'password': password}, auth=False)
+ else:
+ obj = self.json_obj('user.login', params={'user': user, 'password': password}, auth=False)
self.__auth = self.do_request(obj)
def relogin(self):
--
2.35.1
Thanks @ghormoon for the patch. I'll test and integrate it. Jan
I've done one more edit, as on the other fork they didn't like string comparison and they have a point, so i changed it to packaging.version.parse. see PR #5
Thank you @ghormoon