Generate Authentication Code¶
POST /api/v1/offline_token/temporary_auth_code/create
Overview¶
Generate a one-time authentication code.
Body Request Parameters¶
| Parameter Name | Type | Required | Description |
|---|---|---|---|
| roles | array | List of role UUIDs Example: ['readOnly'] Allow empty: False |
|
| roles[*] | string | Y | Role identifier Allow empty: False |
| expires | integer | Y | Token expiration time (in seconds) Example: 3600 Allow empty: False $maxValue: 604800 $minValue: 1 |
Parameter Supplementary Notes¶
Usage Instructions
This interface does not directly return a token, but only returns a one-time authCode.
It is suitable for scenarios where authentication credentials need to be passed to the frontend via page parameters, but you do not want to expose the real token directly.
- Construct the direct login authentication intermediate page address
/redirect_auth/{authCode}?overwrite=true&to=xxx; the intermediate page will exchange the authCode for a real token. - The parameter overwrite=true indicates overwriting the currently logged-in token; (default can be omitted, meaning a temporary token);
- The parameter to=xxx indicates the page address (relative address) to jump to.
- After a successful exchange, the
authCodewill become invalid immediately; if no further use is needed, you can actively invalidate it by callingPOST /offline_token/temporary_auth_code/revoke.
Precautions
authCodecan only be used successfully once.authCodewill automatically expire after the time specified byexpiresIn.- The frontend should use
authCodeto exchange for a real token, and should not useauthCodedirectly as a token.