confirm / PhpZabbixApi

A PHP library for the Zabbix™ JSON-RPC API.
MIT License
115 stars 62 forks source link

Support new auth in 6.4 #83

Open fliespl opened 1 year ago

fliespl commented 1 year ago

Feature Request

New authorization allows api token.

For all people coming in here needing to utilize it, you can use it as follows (setAuthToken won't work).

$options = [
            \GuzzleHttp\RequestOptions::HEADERS => [
                'Authorization' => 'Bearer ' . $_ENV['ZABBIX_TOKEN']
            ]
        ];
        $this->zabbixApi = new ZabbixApi('https://' . $_ENV['ZABBIX_DOMAIN'] . '/api_jsonrpc.php', null, null, null, null, null, null, $options);
plfiumi commented 1 year ago

Hi, this is not working for me, I'm getting a "Not authorized." response. I've generated a token for super admin user, should be access to everything. Any idea? :)

fliespl commented 1 year ago

@plfiumi can you share example of code you are using? Maybe you set username / password as well? In my case.

We are using this piece for a few weeks now without issues.

plfiumi commented 1 year ago

Finally, I'm using this library: https://github.com/intellitrend/zabbixapi-php

Thanks for your help :).