Skip to content
Niu DocsNiu 牛元文档
Dashboard控制台

Use an existing user access token in the browser

Generated from the checked-in source. Do not edit this reference by hand.

POST /api/v1/auth/browser/token

Requires an explicit trusted same-origin Origin and a valid durable Operator session token. Installation credentials, inference keys, revoked sessions and expired sessions are refused. Sets the existing HttpOnly SameSite cookie to the original token without creating an identity or session, extending expiry, changing role/scope, or returning the token in JSON. Cookie lifetime is capped at the original remaining lifetime and eight hours; every subsequent request rechecks the original durable session. Requires configured browser authentication origin. Responses are not cached.

Operation: exchangeOperatorTokenForBrowserSession.

No OpenAPI security scheme is required. Other request validation still applies.

JSON
[]

Set NIU_ORIGIN to your installation origin (without /v1). Replace path, query and header placeholders with the required values. Query examples use curl 7.87 or newer to encode values with --url-query. Use the credential scope described above; a bearer token must have the authority required by this operation.

Shell
curl --fail-with-body -X POST "$NIU_ORIGIN/api/v1/auth/browser/token" \
-H 'Origin: <ORIGIN>' \
-H 'Content-Type: application/json' \
--data @request.json

Location: header. Required. Exact configured browser origin, matching the trusted same-origin UI. A missing, mismatched or cross-site origin is refused.

JSON
{
"type": "string",
"format": "uri"
}

Required.

JSON
{
"type": "object",
"additionalProperties": false,
"required": [
"token"
],
"properties": {
"token": {
"type": "string",
"minLength": 74,
"maxLength": 74,
"pattern": "^niu_admin_[0-9a-f]{64}$",
"writeOnly": true,
"description": "Original user access token; never place it in a URL or browser storage."
}
}
}

Original session established as an HttpOnly browser cookie; no response body.

Response headers:

JSON
{
"Cache-Control": {
"schema": {
"type": "string",
"const": "no-store"
}
},
"Set-Cookie": {
"description": "Existing original Operator session transported in the protected HttpOnly SameSite browser cookie, with lifetime bounded by its original expiry. No cookie value example is provided."
}
}

Malformed JSON or unknown request fields.

Invalid, expired, revoked or non-Operator credential.

Missing, untrusted or cross-site Origin.

Browser authentication origin is not configured.

Durable authentication storage is unavailable.

Requires an explicit trusted same-origin Origin and a valid durable Operator session token. Installation credentials, inference keys, revoked sessions and expired sessions are refused. Sets the existing HttpOnly SameSite cookie to the original token without creating an identity or session, extending expiry, changing role/scope, or returning the token in JSON. Cookie lifetime is capped at the original remaining lifetime and eight hours; every subsequent request rechecks the original durable session. Requires configured browser authentication origin. Responses are not cached.

Supported scope: implemented