0

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

Bill Armstrong
  • 1,615
  • 3
  • 23
  • 47
  • This Basic [token example](https://stackoverflow.com/questions/74779027/how-do-i-send-a-fetch-request-to-paypals-oath-api-v2/74779229#74779229). – Bench Vue Dec 31 '22 at 15:47
  • @BenchVue - That example uses the same method as Ansibles `b64encode` and `b64decode`. I've tried both. The decode throes a no a `latin-1` codec error. – Bill Armstrong Dec 31 '22 at 20:31
  • You need to success from postman first, it success can figure out base64 problem or other's issue. Did you success it by Postman? – Bench Vue Jan 01 '23 at 13:34

0 Answers0