Choosing a Credential
Section titled “Choosing a Credential”Before an external client can call the OSOS API it needs a credential the gateway will accept, and picking the wrong kind is the most common way an integration starts on the wrong foot. The gateway understands two credential shapes: an OAuth 2.0 bearer token in the Authorization header, validated by introspection, and a long-lived application token in the x-app-token header. Behind the first sit several grant types, each meant for a different kind of caller.
This page owns one decision: which credential fits which caller. It does not explain how to mint any of them — Authentication & OAuth covers the OAuth provider, its grants and endpoints in depth, and API Tokens covers creating and managing application tokens. Once you have decided, the quickstart takes you from a fresh token to a working call.
The decision at a glance
Section titled “The decision at a glance”| You are building… | Use | Because |
|---|---|---|
| An interactive app a person signs into (web, mobile) | OAuth authorization code + PKCE | The platform hosts login, consent, MFA and passkeys for you; the user’s own identity flows through. |
| A trusted first-party script that holds a user’s credentials | OAuth password grant | Direct exchange of username/password for tokens — acceptable only when the script can safely hold a raw password. |
| A headless service, integration or scheduled job | Application token (x-app-token) | No token exchange, no refresh loop; a stable machine identity with exactly one user’s permissions. |
| A third-party product acting on behalf of your users | OAuth authorization code with consent | Each user authorizes your client individually; you never see credentials, and one user revoking does not affect another. |
The rest of this page walks each row, then covers the limits of the application token — the credential most headless clients end up with.
An interactive user
Section titled “An interactive user”Use the authorization code flow with PKCE. The shipped SPA clients (osos-dev, osos-uat) are the pattern to copy: token_endpoint_auth_method: "none" (a public client), authorization_code + refresh_token grants, and wildcard subdomain redirect URIs so one client registration serves every tenant subdomain. Clients are provisioned statically — there is no dynamic registration endpoint — so registering yours means adding it to the clients file (or its additional-clients.json override) and restarting the identity service. Since 1.10 those files are a seed written into the tenant’s client collection at boot, and in a multi-tenant deployment the standard clients are templated per tenant instead (see Per-tenant OpenID Providers). A browser page that only needs anonymous access uses POST /api/identity/v1/anonymous/token — never a client secret in the browser.
Two behaviours the provider gives interactive clients for free, both verified:
- A public web client receives a refresh token even without requesting
offline_access(issueRefreshToken), so sessions survive access-token expiry. - The hosted login UI presents whatever factors the tenant has enabled — password, OTP, passkeys, external identity providers — without your client implementing any of them.
A trusted first-party script
Section titled “A trusted first-party script”The provider registers a custom password grant: the script posts a username and password to /token and receives tokens directly. This is the right shape only when first-party and trusted both genuinely hold — the script sees the raw password, so it must be yours, and the account is subject to normal account policy (bad credentials count toward lockout).
Weigh it against an application token before choosing it. The password grant ties your automation to a human account: its permissions change when the person’s do, its password rotates on the person’s schedule, and a lockout stops your job. If the script is really a service in disguise, a dedicated application user with its own token is the more stable identity.
A headless service
Section titled “A headless service”Use an application token. It is minted for a dedicated application user — a USER entry whose type is APPLICATION_USER — and sent as x-app-token on every request. The gateway’s app-token-auth plugin validates it against the identity service and injects the owning user’s id as x-user-id; from there the request is indistinguishable from that user acting directly. There is no OAuth exchange, no refresh loop, and no session to keep alive — the operational lifecycle it does have (expiry, rotation, revocation) is covered in Token Lifecycle.
Why not client_credentials? The machine-to-machine grant exists and is enabled, but a client-credentials token identifies a client, not a user: its introspection result carries no subject, so the gateway forwards no x-user-id, and downstream services resolve the caller to a profile with empty permissions. The request authenticates — and then can read almost nothing, because the data plane authorizes users, not clients. The grant only becomes useful in combination with the gateway’s trustedClientId impersonation configuration, which is a deployment-level trust decision for internal infrastructure, not an application pattern. For a headless caller that needs to see tenant data, the application token is the supported answer. The one surface it does not open is the real-time socket, which needs a user’s OAuth token: for a service, the password grant for a dedicated ordinary user — an application user cannot sign in with a password (Subscribing to events).
A third party acting for a user
Section titled “A third party acting for a user”Run the authorization code flow and let each user consent. The shipped zapier, wordpress and n8n-localhost clients in clients.json are working examples of exactly this pattern: a fixed redirect URI on the third-party side, authorization_code + refresh_token grants, standard scopes.
Two tempting shortcuts, and why they are wrong here:
- Not the password grant. A third party must never handle users’ passwords; the grant exists for first-party trust only.
- Not a shared application token. An application token has one fixed identity, so every user’s actions would be attributed to the same application user, per-user permissions would collapse into one profile, and revoking one customer’s access would mean revoking everyone’s.
The platform’s delegation mechanism (the X-Delegation-Id header) is not this either: it lets one person act for another inside the platform during an authorized window, and is not a machine-integration surface. It is covered in Tenancy and Identity.
What an application token cannot express
Section titled “What an application token cannot express”An application token carries no scopes. The stored token document holds identity and lifecycle metadata — the argon2 hash, a name, active/expiry flags — and nothing else; the gateway consumes only the owning user’s id from a successful validation. There is no field anywhere in that path that could narrow a token to “read-only” or “this entity only”.
Everything the token may do is therefore decided by the owning application user: its roles, its space memberships, its view permissions. This has three practical consequences:
- Least privilege is modelled on the user, not the token. Create a dedicated application user per integration and grant it exactly what that integration needs.
- One integration, one token. Since a token cannot be scoped down, isolation between integrations comes from separate owning users — which also makes revocation surgical.
- Auditing follows the user. Actions appear as the application user, so a shared token across several systems destroys attribution.
The same inheritance also bounds the token spatially: it can only operate in spaces its owning user belongs to, which is enforced per request at the gateway — see Tenancy and Identity.
Deciding quickly
Section titled “Deciding quickly”If a person is present at a screen, use authorization code + PKCE. If no person is present and the caller is yours, use an application token owned by a purpose-built application user. If no person is present but the caller belongs to someone else, make their users consent through the authorization code flow. Reserve the password grant for the narrow case of a first-party script that genuinely must hold a password, and treat client_credentials as infrastructure plumbing rather than an integration credential.
Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27