API reference
How your app, your backend and Otoko Identity talk to each other, and where each call is described.
Register an app, sign people in, and, if your app has a backend, answer the calls Otoko Identity makes to it. The Quickstarts do it from start to finish for each kind of app; these pages describe each part in full.
How it works
An app is one product using Otoko Identity. A client is one way of signing in to it, and an app can have several.
- People sign in on Otoko Identity's own pages. Your app sends the browser there, and gets back a code it swaps for tokens: the OpenID Connect code flow, with PKCE.
- Your app's backend checks the tokens it is sent, with the keys Otoko Identity publishes.
- Otoko Identity calls your backend too, with a secret only the two of you hold. It asks whether a person may sign in, and tells it which sessions ended.
- A backend is optional. An app with none gets no calls, and its roles are managed in the console.
- By default, sign-up, email verification, forgot password and invitations run on Otoko Identity's own pages.
- Apps are kept apart: an identity belongs to one app, so the same email in two apps is two accounts. API keys, browser sessions and counters never cross.
- A new app needs no change to any file and no restart. It works at once in the process that made it, and in the others within about 50 seconds.
- A mobile app signs in through your backend instead, with no browser pages, so it needs a backend. See Mobile apps.
Before you start
- Have your app's sign-in redirect addresses ready. They are exact and absolute, with no wildcards or fragments, a lowercase scheme and host, and https outside a local environment.
- Whatever origin a redirect address has may call the sign-in API from then on.
- If your app has a backend, have its address ready. It is https outside a local environment, and its name may not lead to a link-local or cloud metadata address, or to loopback outside a local environment, because Otoko Identity sends tokens to it. That is checked when you save and again at every call.
- A backend needs the sign-in check route before anyone can sign in. See The sign-in check.
- Choose who sends the app's emails. Sign-in codes, sign-up, password reset and invitations all send email. Connect an app ticks Send this app's emails through Otoko Identity's mail server, so the app needs no mail server of its own. Untick it to use the app's own, and have its host, port, encryption, username and password ready: Connect an app asks for them, and saves them once the app is made. An app whose chosen mail server isn't set up sends nothing.
Who calls whom
| Who calls | What | Proves who it is with | See |
|---|---|---|---|
| The browser or your app | /oauth/ and /.well-known/ at the Issuer: sign-in, tokens, sign-out, keys | PKCE, and a confidential client's secret | OpenID Connect |
| Your backend | /internal/ at the Issuer: people, sessions, codes, passkeys, invitations | The app's API key, as a bearer token | Your backend's calls |
| Otoko Identity | /internal/ on your backend: the sign-in check, new accounts, ended sessions | The webhook secret, as a bearer token, and a signature on account.created | Calls to your backend |
| Your backend, on every request | The access token it is sent | Otoko Identity's published keys | Tokens |
Your backend
Give your backend these settings. The names are a suggestion, the ones the Connect an app kit shows, and a backend may call them anything.
| Name | What it holds |
|---|---|
IDENTITY_URL | The Issuer, this service's address. |
IDENTITY_APP_ID | The app's id. |
IDENTITY_API_KEY | What the backend calls Otoko Identity with. Shown once, when the app is made. |
IDENTITY_CALLBACK_TOKEN | The webhook secret. Otoko Identity sends it on every call to the backend. |
IDENTITY_WEBHOOK_SIGNING_SECRET | The app's webhook signing secret, whsec_ and base64, made on its Security tab. Checks the signature on account.created. |
IDENTITY_ALLOWED_CLIENT_IDS | The client IDs of the app. Tokens must name one of them in both aud and azp. |
Settings for your backend:
IDENTITY_URL=https://identity.example.com
IDENTITY_APP_ID=your-app-id
IDENTITY_API_KEY=the-api-key-shown-once
IDENTITY_CALLBACK_TOKEN=the-webhook-secret
IDENTITY_WEBHOOK_SIGNING_SECRET=whsec_the-signing-secret-shown-once
IDENTITY_ALLOWED_CLIENT_IDS=your-client-idWith no backend, the kit gives only IDENTITY_URL, IDENTITY_APP_ID and IDENTITY_API_KEY, for a server of yours that calls Otoko Identity, such as to invite people.
In this section
OpenID Connect
Sign people in and out, the flow, and the endpoints, scopes and claims.
Calls to your backend
The sign-in check, new accounts and their signatures, ended sessions and the sign-up check.
Your backend's calls
Every route under /internal/v1 your backend calls with the API key.
Tokens
Checking tokens, making your user on its first request, and lifetimes.
Errors
Every error code, and what to do about it.
The console's switches that aren't calls, such as account flows, required actions and roles, are under App settings, starting with Account flows.