OpenFolia

Issue a token

POST
/service-accounts/{serviceAccountId}/tokens

A new bearer token for the service account, in meta.token: shown only in this answer; only its hash is stored. It expires (by default in 90 days, at most 366); send it as Authorization: Bearer <token>. Recorded as service-token.issue (its ID and expiry, never the token). Changes apply at once (from the next request of the service account) and are recorded in the audit log. Needs admin.roles, held by a user: a service account cannot change access, whatever its roles.

Authorization

bearer
headerAuthorizationBearer <JWT>

A service account's token (ccms_sat_…, issued by POST /service-accounts/{id}/tokens), or, for local use and demo mode, the server's shared CCMS_API_TOKEN.

Path Parameters

serviceAccountId*string

The service account’s ID. One that names no service account is 404.

Header Parameters

X-Ccms-User?string

Demo mode only (CCMS_AUTH_MODE=demo): the user ID to act as. The bearer token is still required; without demo mode the header is refused (400).

Request Body

application/vnd.api+json
  1. body
data*

Response Body

application/vnd.api+json
  1. response
data*

A token of a service account, as listed: never the token itself, which is shown only once, when issued. id is the token’s public part (ccms_sat_<id>_…).

meta*
Example Request
curl -X POST 'http://localhost:3000/service-accounts/string/tokens' \  -H 'Content-Type: application/vnd.api+json' \  -d '{  "data": {    "type": "ServiceToken",    "attributes": {      "name": "string"    }  }}'
Example Response
{  "data": {    "type": "ServiceToken",    "id": "string",    "attributes": {      "name": "string",      "createdAt": "2019-08-24T14:15:22Z",      "expiresAt": "2019-08-24T14:15:22Z",      "lastUsedAt": "2019-08-24T14:15:22Z",      "revokedAt": "2019-08-24T14:15:22Z"    },    "relationships": {      "serviceAccount": {        "data": {          "type": "ServiceAccount",          "id": "string"        }      }    }  },  "meta": {    "token": "string"  }}