Zero-key onboarding: device codes, consent, grants and approvals
Kovlet apps get access to data without an API key. The person running the app signs in and approves it once, and Kovlet does the rest.
On this page
At a glance
- No secret ships in app code. The code only says which tables it needs and whether it reads or also writes.
- Apps that can open a browser show a consent screen. Scripts, CLIs and coding agents show a short device code instead.
- Approving creates a grant: viewer or editor access to a Data Space, for that app.
- An app that needs more spaces later asks for them with a link. Nobody signs in again.
- A workspace admin can also require that apps and machines are approved before they work.
What the app declares
An app built with @kovlet/client names itself and its slotsA named placeholder for a Data Space, filled in when someone approves the app., with no key. A slot is a placeholder for a Data Space: a name, the tables the app expects there, and the role it needs.
import { createKovletClient, t } from "@kovlet/client";
export const kovlet = createKovletClient({
appName: "Receipt Scanner",
spaces: {
finance: {
role: "editor",
tables: {
expenses: { vendor: t.string(), amount: t.number(), spentAt: t.datetime() },
},
},
},
});finance is a slot: a name the app's code uses, not a Data Space id. Kovlet maps each slot to a real Data Space when the user approves the app.
The app's identity comes from where it runs: its web origin, its redirect URI or its device key. So nothing in the code can be copied and reused by another app. The web quickstart has a complete app.
Two ways to sign in
Which flow an app uses depends on whether it can open a browser and get sent back.
- Consent (an OAuth authorization code with PKCE) is for apps that can. Web, mobile and desktop apps open
https://kovlet.com/oauth/consent. The user picks or creates a space for each slot, and the app gets a session. - Device code is for apps that can't redirect back from a browser. The app prints a link and a code such as
4FKD-XMMY. The user openshttps://kovlet.com/activate, confirms the code and approves. Codes expire after 10 minutes.
| Consent (authorization code + PKCE) | Device code | |
|---|---|---|
| For | Web apps, iOS, Android, desktop apps that can open a browser | CLIs, Node scripts, servers, coding agents, devices without a browser |
| What the user sees | A popup or browser sheet: sign in, then "Allow Receipt Scanner on…" with a space picker per slot | A printed link and code; they open /activate, check the code, pick spaces and approve |
| Session | Bound to a device key, 30 days, refreshes itself | With a device key: bound, 30 days, refreshes. Without a key: a headless machine, 90 days, no refresh |
| Used by | @kovlet/client in browsers, Swift .webAuthentication, Kotlin SignIn.customTab, Tauri sign_in | @kovlet/client in Node, Kotlin SignIn.device, Tauri { flow: "device" }, the Kovlet MCP server, REST clients |
Both flows end the same way:
- a session token (
kvs_…) whose user, machine and app are known, - grants that say which spaces the app may use.
The sync protocol reference lists every HTTP step.
The device key
The device key ties a session to one device, so a stolen token is useless on its own.
- Before signing in, the app creates a P-256 key pair it can't export. Browsers keep it with WebCrypto in IndexedDB. Apple platforms use the Secure Enclave or Keychain, Android uses Android Keystore, and elsewhere it goes in the OS keychain or a private file.
- The public half is sent at sign-in.
- Every later request carries a fresh signature (
Kovlet-Device-Proof).
The same key and user always map to the same machine. So signing in again keeps the machine's name, approval and grants.
Consent and slots
At consent the user decides two things for each slot the app declared.
Which Data Space the slot uses:
- an existing Data Space they can access, or
- a new Data Space, named after the app by default. Pressing Approve on a first run does this.
Which role the app gets on it: viewer or editor. It is never more than the user's own role on that space.
The answer maps each slot to a space id. In the token response it looks like spaces: {"finance": {"space_id": "…", "role": "editor"}}. An owner can pin spaceId on a slot in code, so teammates skip the picker.
Grants
A grant is the record that lets an app, a machine or a person use a space:
| Grant | Written when | Holds |
|---|---|---|
App grant (Space, App) | A user approves an app at consent, by device code with a key, or a coding agent | viewer or editor |
Machine grant (Space, Machine, App) | A user approves a headless workload: a device code without a key, or a Machine Auth Key | viewer or editor, plus the optional impersonate flag for acting as an end user |
User grant (Space, User) | An owner shares the space with a person, invites a guest, or creates the space | viewer, editor or owner |
An app's effective role is the lower of the user's role and the app's grant (access model). Approving never lowers a grant an app already holds.
More spaces later: grant requests
An app that is already signed in can ask for more spaces without a new sign-in.
- The app makes a grant request:
kovlet.requestSpaces(...)in the SDK,POST /v1/grant-requestsover REST, orrequest_space_accessfrom the MCP server. - Kovlet returns an approve link.
- The user opens it, picks or creates spaces, and approves.
- The app polls for the result.
Only the user who signed the app in can open the link. It expires after 10 minutes.
An app can also create a new space for itself (POST /v1/spaces). The signed-in user owns it.
Approvals
Approval is the workspace's trust decision about an app or a machine. It is separate from any grant: a grant says what an app may use, and approval says whether the workspace trusts it at all.
- Apps. An app is registered the first time a user approves it. It starts approved when that user is an admin or owner of the workspace (always true in a Personal Workspace), and pending otherwise.
- Machines. A machine is enrolled when someone signs in on it. The same rule applies: approved when that user is a workspace admin or owner, pending otherwise.
- When it matters. Pending apps and machines work normally, unless the space or its workspace turns on *Require approved apps* or *Require approved machines*. Then they get
app_not_approvedormachine_not_approveduntil an admin approves them in the console. - Revocation is separate again. A revoked app or machine is cut off everywhere, approved or not.
Other things in Kovlet are also "approved", but by a space owner and for a different reason:
- destructive schema proposals,
- rules proposals from the MCP tool
propose_rules.
Coding agents
A coding agent connects the same way, with a device code.
npx -y @kovlet/mcp initsets up the Kovlet MCP server.- The first tool call returns an
/activatelink and code. - The user picks the Data Spaces the agent may use.
The agent's session is bound to the approving user. So it never sees or does more than that user. See connect a coding agent.
Local development
Against kovletd --dev, approval links point at the local console (http://localhost:5173).
Without a console, you have two options:
- approve a device code from a terminal with
kovletd dev approve <user_code>, - start the server with
--dev-auto-approve.
See run Kovlet locally.
Next
- Sync and conflict resolution: what happens after the app connects.
- Access model: how grants combine into an effective role.
- Glossary.
Ready to try it? Start free. No credit card, no API keys.
For coding agents: this page is also Markdown. Add .md to the URL or send Accept: text/markdown. The full reference is at /llms-full.txt.