Authentication
Every endpoint in this API requires an access token. Tokens come from UAC’s Keycloak using the OAuth 2.0 client credentials grant. It’s a machine-to-machine flow, so there’s no user to redirect and no browser involved.
1. Get a token
The response:
2. Use it
Send the access_token as a bearer token on every request:
3. Reuse it until it expires
expires_in is the lifetime in seconds, currently 1800 (30 minutes).
You should NOT:
- Request a new token for every API call as it hammers Keycloak during bulk loads.
- Cache a token forever and ignore its expiry.
Instead, hold the token in memory, note when it expires, and fetch a new one shortly before it does.
Read expires_in rather than hardcoding 1800. The realm’s token lifetime can
change without the API changing.
What the token carries
Your identity travels in the token itself, which has two practical consequences:
- You never pass an
institutionIdin a request. There is no parameter for it. - Writes are attributed automatically, so audit fields such as a document’s
uploadedByare filled in for you.
Credentials
UAC issues your client_id and client_secret. You can’t create them yourself, so contact
UAC if you don’t have them or a secret needs rotating.
The client secret has full access to your institution’s data, and anything holding it can act as your institution. Keep it server-side. It should never appear in a browser, a mobile app, a public repository or a CI log.
Use an environment variable or a secrets manager, not a literal in source. In the examples
above, $CLIENT_SECRET is read from the environment for exactly this reason.
Environments
Each environment has its own API host. The Keycloak realm is shared between them, so the same credentials work against both, and a token minted for one will be accepted by the other. Be deliberate about which host you point at.
Each environment also serves its raw OpenAPI document at /q/openapi.json under the same
base URL, if you’d rather generate a client than read pages.
When it goes wrong
For the endpoint reference, see Get access token.
