zabbix-tools / go-zabbix

Go bindings for the Zabbix API
GNU General Public License v2.0
108 stars 70 forks source link

Create session with existing token #36

Open sigmonsays opened 4 years ago

sigmonsays commented 4 years ago

If I have an existing token, there seems to be no way to create a session with a token and a *http.Client

If I construct a *Session manually i can specify a token, however client is not exported I can't specify a token and set a custom http client. By exporting client we achieve both.

I made a PR #35 to address this.

mr-ns commented 1 year ago

Yes, please please please export the client field in Session. Alternatively, provide a way to set Session.client that does not require login (as happens via CreateClient()...Connect()). Here is my use case:

I am calling the Zabbix user.checkAuthentication API, which means (like the OP) I already have an existing API token. Because I am not logging in I cannot use the CreateClient()...Connect() approach to acquire a Session. Normally I would just create a new instance of Session, however in my particular case Zabbix is using a self-signed cert so I need to slip in a custom http.Client with InsecureSkipVerify = true. Because Session.client is not exported I have no way to do this.