Quickstart
Five steps from zero to a working ScaiKey access token. We'll use the client_credentials grant because it's the shortest path: no user, no browser, two curl calls.
If you need an interactive user-login flow instead (browser redirect, login page, consent), see Tutorials → Integrate a web app.
Prerequisites#
- A ScaiKey instance you can talk to. The public ScaiLabs deployment is at
https://scaikey.scailabs.ai. We'll use$SCAIKEYas a placeholder. - A super_admin in the ScaiKey admin UI (or a partner_admin if you're scoped to a partner).
1. Register an application#
Log in to the admin UI ($SCAIKEY/admin/) and create a new application:
- Type:
SERVICE(machine-to-machine; uses a client secret). - Scope:
GLOBALif it's cross-tenant, otherwiseTENANTand pick the tenant. - Allowed scopes: add at least
openid. If this service will call ScaiKey's admin API, also addadmin:read(andadmin:writeif it will modify resources).
Save it. The UI shows you the client_id and a one-time client_secret. Copy both.
1 2 3 | |
2. Request an access token#
1 2 3 4 | |
Use /api/v1/platform/oauth/token for GLOBAL apps; use /api/v1/auth/tenants/{slug}/oauth/token for TENANT-scoped apps.
Response:
1 2 3 4 5 6 | |
3. Decode the token (optional but recommended)#
1 2 | |
You should see something like:
1 2 3 4 5 6 7 8 9 | |
sub equals client_id for service tokens — this is how downstream services identify the calling principal.
4. Call a protected endpoint#
1 2 | |
You should see your tenants. If you get 403 Platform token requires admin:read or admin:write scope, your token doesn't have the scope — go back to step 1 and add it to the application's allowed scopes.
5. Tokens expire — refresh by re-requesting#
client_credentials tokens don't come with a refresh token (intentional). When expires_in runs out, just repeat step 2. Most clients cache the token in memory and re-request a few seconds before expiry.
Where to go from here#
- Concepts → OAuth and OIDC — every grant we support and when to use each.
- Concepts → Tokens and scopes — what's in the JWT, how scopes work.
- Reference → OAuth endpoints — every endpoint, every parameter.
- Troubleshooting — common errors and what they mean.