Skip to main content
Every API request needs a Bearer access token in the Authorization header.

Set your environment

Examples in these docs use two shell variables so you can paste them as-is. Set both once per session.
$BASE_URL is your environment’s host. It differs per environment, so substitute the one we issued with your tenant. See Base URLs.

Get a token

Submit your clientId and clientSecret to Keycloak with the client_credentials grant.
Use --data-urlencode rather than --data, because secrets often contain +, &, or %, which are meaningful in form encoding. With plain --data those characters go through as-is and Keycloak receives a different secret, which fails with invalid_client.
You receive:
The token is valid for five minutes (expires_in: 300). There is no refresh token (refresh_expires_in: 0); when the token expires, request a new one with the same call.

Use the token

Capture it into $ACCESS_TOKEN, which every other example expects:
Then include it in every API request:
The token lasts five minutes. Re-run the export when it expires. The gateway rejects a stale token as a plain-text 403, not a JSON error. See Error handling.