API: Authentication
Log in with Basic username/password credentials, then send the returned access token as
Authorization: Bearer {ACCESS_TOKEN} on authenticated API requests.
Use the v2 login, refresh, and logout endpoints to manage renewable sessions. Both login versions require Basic credentials; a Bearer token cannot be used in place of them.
Login (v2)
Each successful login creates an independent refresh session.
The JSON response contains:
| Field | Meaning |
|---|---|
accessToken |
JWT used for authenticated API requests |
refreshToken |
Opaque token used to renew this session |
tokenType |
Always Bearer |
expiresIn |
Access-token lifetime in seconds |
refreshExpiresAt |
Fixed refresh-session expiry as a date-time |
For example, curl --user prompts for the password when only a username is supplied:
Store both tokens securely. Login and refresh responses must not be cached. Use the
server's certificate authority with --cacert when it is not already trusted.
Refresh (v2)
Send the current refresh token in the JSON body. This endpoint does not require an Authorization header.
A successful response has the same fields as login and replaces both tokens. The
previous refresh token becomes unusable. Reusing it revokes the entire refresh session,
so serialize refresh requests and replace the stored token pair together. Rotation does
not extend refreshExpiresAt.
A missing or blank token returns 400. An invalid, expired, or revoked token returns
401; log in again with Basic credentials.
Logout (v2)
Logout revokes the refresh session identified by any of its refresh tokens.
The endpoint returns 204, including for unknown or already revoked tokens. A missing
or blank token returns 400. Existing access JWTs remain valid until their expiry;
logout prevents further renewal of this session.
Login (v1 compatibility)
The v1 login endpoint is deprecated but remains available with Basic credentials. Its response is a JWT string, rather than the v2 token object.
Pass that string as Authorization: Bearer {JWT_TOKEN} on subsequent requests. Use v2
when an integration needs renewable sessions.
Token lifetimes
The v2 access token lasts 900 seconds (15 minutes) by default. Its refresh
session lasts 604800 seconds (7 days), measured from the initial login; refresh
rotation does not extend that deadline. Server administrators can set
tuoni.auth.tokens.access-expiry-seconds and
tuoni.auth.tokens.refresh-expiry-seconds to positive values.
The separate tuoni.auth.jwt.expiry-seconds setting controls JWTs returned by
the legacy v1 login endpoint. It does not change v2 access or refresh lifetimes.
WebSocket authentication and browser origins
WebSocket connections enforce access-token expiry and current permissions. Custom clients must obtain a valid access token and reconnect when their connection's token expires. Refreshing a REST token does not renew an existing WebSocket connection.
Browser connections use same-origin checks by default. If the browser client is served from a different origin, configure its exact scheme, hostname, and port:
Use the origin seen by the browser, including any nondefault port. Wildcard origins are not supported. See Setting Up the C2 for deployment configuration. For the endpoint, subscriptions, permissions, and message shapes, see WebSocket events.