Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support to new auth token #142

Open
pariseed opened this issue Jun 8, 2021 · 8 comments
Open

support to new auth token #142

pariseed opened this issue Jun 8, 2021 · 8 comments

Comments

@pariseed
Copy link

pariseed commented Jun 8, 2021

as zabbix 5.4 introduced support for auth token, is planned to integrate this feature in this python module ?

@anshibanov
Copy link

+1

@HuiMi24
Copy link

HuiMi24 commented Sep 22, 2021

zapi.login(api_token="xxx")
it could work with this parameter.

@ByteDSM
Copy link

ByteDSM commented Nov 5, 2021

zapi.login(api_token="xxx")
it do not work
v. 5.4.7

@HuiMi24
Copy link

HuiMi24 commented Nov 18, 2021

zapi.login(api_token="xxx") it do not work v. 5.4.7

I'm using 5.4.4. The token generated at "Administration -> General -> API token"

@xterms013
Copy link

Hi all! I not found support for api tokens in "/usr/local/lib/python3.8/dist-packages/pyzabbix/api.py". It seems like api tokens not supprorted now. Is planned to integrate this feature in this python module ?

Or am I wrong?

@jnunezgts
Copy link

Is not supported. Actually this feature would be super useful as it will save the cost of authenticating with user and password, when you can just persist your session and reuse it (if it expired the log in again and get a new one)

@gdeleon23
Copy link

Hi, i think this is fixed, i can use a token with pyzabbix in version 6.0.19
module python pyzabbix: pyzabbix==1.3.1

code of script:

import urllib3

URL='https://zabbix.xxxx.xxx'
TOKEN='xxxxxxx'

urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

zapi = pyzabbix.ZabbixAPI(URL)
zapi.session.verify = False
zapi.timeout = 5.1

# check token
print("Zabbix version ( not need authentication): ", zapi.api_version())
try:
    print(zapi.user.checkAuthentication(token=TOKEN))
except ZabbixAPIException as error:
    print("Login error %s" % error)
    exit(1)
print("Login OK")
# do Login
zapi.login(api_token=TOKEN)
print(zapi.host.get(host="Zabbix server", output="host"))

Execution:

> python3 test_zabbix_token.py

Zabbix version ( not need authentication):  6.0.19

{'userid': '1', 'username': 'Admin', 'name': 'Zabbix', 'surname': 'Administrator', 'url': '', 'autologin': '1', 'autologout': '0', 'lang': 'en_US', 'refresh': '30s', 'theme': 'default', 'attempt_failed': '0', 'attempt_ip': '192.168.128.1', 'attempt_clock': '1708981804', 'rows_per_page': '50', 'timezone': 'system', 'roleid': '3', 'type': 3, 'userip': '172.31.0.1', 'debug_mode': 0, 'gui_access': 0}

Login OK

[{'hostid': '10084'}, {'hostid': '10700'}, {'hostid': '10704'}]

@pariseed
Copy link
Author

pariseed commented Apr 9, 2024

@gdeleon23 hey man now there's the official python module from Zabbix, no more need to use third party modules, check it out at github.com/zabbix/python-zabbix-utils

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants