boswelja
Cadet
- Joined
- Apr 18, 2023
- Messages
- 2
Hey all,
I am currently trying to set up an authentication flow in an Android app using the TrueNAS API v2.0, but I've noticed I cannot use any of the endpoints via bearer token generated by `/auth/generate_token`.
For example, if I try to hit `/reporting/graphs`, I will get a 401 Unauthorized. In this example, the request looks like this:
To generate a new token, I am sending this:
Which seems to work, and returns a new token (wrapped in quotes, which I have stripped in the hopes that it would fix the issue but it did not).
I'm not super familiar with the authentication side of RESTful services, so I'm probably missing something simple here
My host server is an HP DL380 G9 (which probably isn't super relevant here) running TrueNAS SCALE 22.12.2
I am currently trying to set up an authentication flow in an Android app using the TrueNAS API v2.0, but I've noticed I cannot use any of the endpoints via bearer token generated by `/auth/generate_token`.
For example, if I try to hit `/reporting/graphs`, I will get a 401 Unauthorized. In this example, the request looks like this:
REQUEST: http://truenas.local/api/v2.0/reporting/graphs
METHOD: HttpMethod(value=GET)
COMMON HEADERS
-> Accept: application/json
-> Accept-Charset: UTF-8
-> Authorization: Bearer my-token-here
CONTENT HEADERS
-> Content-Length: 0
BODY Content-Type: null
BODY START
To generate a new token, I am sending this:
REQUEST: http://truenas.local/api/v2.0/auth/generate_token
METHOD: HttpMethod(value=POST)
COMMON HEADERS
-> Accept: application/json
-> Accept-Charset: UTF-8
-> Authorization: Basic my-basic-auth
CONTENT HEADERS
-> Content-Length: 43
-> Content-Type: application/json
BODY Content-Type: application/json
BODY START
{"ttl":600,"attrs":{},"match_origin":false}
BODY END
Which seems to work, and returns a new token (wrapped in quotes, which I have stripped in the hopes that it would fix the issue but it did not).
I'm not super familiar with the authentication side of RESTful services, so I'm probably missing something simple here
My host server is an HP DL380 G9 (which probably isn't super relevant here) running TrueNAS SCALE 22.12.2