For either using username or token authentication in Splunk, I wrote a small wrapper for the connect
function.
The advantage compared to the existing connect
function is that you can use the same line of code for both authentication methods depending on the parameters that you pass (here shown by using ENV variables):