go-zabbix icon indicating copy to clipboard operation
go-zabbix copied to clipboard

Create session with existing token

Open sigmonsays opened this issue 5 years ago • 1 comments

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.

sigmonsays avatar Jun 29 '20 18:06 sigmonsays

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.

mr-ns avatar Feb 23 '23 22:02 mr-ns