Auto-login¶
Auto-login uses a short-lived token to sign in without entering a password again. Issue a link only to a user already authenticated by your external system. Anyone receiving the link gains access to the account for which the token was issued.
Get a token¶
An ordinary user session or personal key can issue a token only for that same user. An administrative role does not remove this restriction. To let an external account management system issue auto-login tokens for users, an administrator creates an API token with the autologin/generate scope and sends it in the request's Bearer header.
The v3 request:
POST /watcher/client-api/v3/autologin/generate
Authorization: Bearer <token>
Content-Type: application/json
{"login":"resident-example"}
The response contains autologin_token. The request supports login; the server sets the token and session lifetimes: the token can be used to sign in for five minutes, and the resulting session lasts eight hours.
Do not put a user's personal key in the URL: the link requires the autologin_token from the response.
Open the web interface¶
Build a link, URL-encoding the token as a parameter value:
https://watcher.example.com/watcher/client/#/auth/signin/auto?autologin_token=<encoded_token>
The web interface reads the token from the parameter after #, exchanges it through the API and stores the resulting session. This workflow does not require the old HTML form posting to a separate auto-login path.
Exchange the token in your application¶
Instead of opening the web interface, an application can send:
POST /watcher/client-api/v3/autologin
Content-Type: application/json
{"autologin_token":"<autologin_token>"}
The response contains access_token and refresh_token, as with regular API login. Send subsequent requests with Authorization: Bearer <access_token>.
An invalid or expired token is rejected with a validation error. Request a new token through the trusted system. Do not store auto-login links in public logs or use one token as a permanent user link.