I'm in the process of writing a series of Ansible tasks for TrueNAS-SCALE-22.12.0. The plan was to use a session token for each playbook to authenticate.
There is an api endpoint auth/generate_token
which will return what looks like a session token when accessed using a basic authentication (user:password).
I've used both Ansible and Postman to test a dozen or so authentication approaches using the token that is generated, and each results in 401: Unauthorized
errors. I've even tried variations of base 64 encoding (just in case).
It is possible to use the basic authentication to generate a user api token, which then can be used as a bearer token in subsequent requests. So my question is not so much about how to achieve my automation goal, but rather to understand what the auth/generate_token
endpoint is for and how to use it.
Here is some background and here are the docs. Not really clear to me.
Edit:
Here's an example of the session token returned by the auth/generate_token
endpoint:
bYYJSTw8U3kZg5QxIyKgeLgPWIQtVKhu0FoGq3oSYWE7kQFCkNxeHWw7zcZbGPvH