···2626- `KANEO_CLIENT_URL` - The URL of the web application (e.g., `http://localhost:5173`)
2727- `KANEO_API_URL` - The URL of the API (e.g., `http://localhost:1337`)
2828- `AUTH_SECRET` - Secret key for JWT token generation (**must be at least 32 characters long**; use a long, random value in production)
2929+- `DEVICE_AUTH_CLIENT_IDS` - Optional comma-separated list of allowed device-flow client IDs (for example `kaneo-cli,my-app`)
2930- `DATABASE_URL` - PostgreSQL connection string
3031- `POSTGRES_DB` - PostgreSQL database name
3132- `POSTGRES_USER` - PostgreSQL username
3233- `POSTGRES_PASSWORD` - PostgreSQL password
3434+3535+If you are testing a CLI or external app against your local Kaneo instance, set `DEVICE_AUTH_CLIENT_IDS` to include the client ID your app sends to `/api/auth/device/code`.
33363437### Development-Specific Variables
3538
+88-2
apps/docs/api-reference/authentication.mdx
···11---
22title: Authentication
33-description: Learn how to authenticate API requests using API keys
33+description: Learn how to authenticate API requests using API keys or the device authorization flow
44---
556677-All API endpoints require authentication using an API key. This guide explains how to create an API key and use it to authenticate your requests.
77+All API endpoints require authentication. Kaneo currently supports two authentication patterns for API access:
88+99+- API keys for scripts, services, and long-lived integrations
1010+- Device authorization for CLIs and external apps that need browser-based sign-in
1111+1212+## Choose an Authentication Method
1313+1414+### API keys
1515+1616+Use API keys when you control secret storage and want a stable credential for a single Kaneo instance.
1717+1818+### Device authorization
1919+2020+Use the device flow when you are building a CLI, desktop app, or other client that should send the user to the browser to approve access.
2121+2222+The device flow follows RFC 8628 and returns a Bearer token that can be used against that Kaneo instance's API.
823924## Creating an API Key
1025···8095});
8196```
82979898+## Using Device Authorization
9999+100100+Before using device authorization on a self-hosted Kaneo instance, the instance operator must allow your client ID through `DEVICE_AUTH_CLIENT_IDS`.
101101+102102+### Flow overview
103103+104104+1. Your app requests a device code from `/api/auth/device/code`
105105+2. Kaneo returns a `device_code`, `user_code`, polling interval, and verification URL
106106+3. The user opens the verification URL in a browser and signs in
107107+4. The user approves the request
108108+5. Your app polls `/api/auth/device/token` until an access token is issued
109109+6. Your app sends API requests with `Authorization: Bearer <token>`
110110+111111+### Request a device code
112112+113113+```bash
114114+curl -X POST https://your-kaneo-instance.com/api/auth/device/code \
115115+ -H "Content-Type: application/json" \
116116+ -d '{"client_id":"your-app-id"}'
117117+```
118118+119119+Example response:
120120+121121+```json
122122+{
123123+ "device_code": "dev_123",
124124+ "user_code": "ABCD-1234",
125125+ "verification_uri": "https://your-kaneo-instance.com/device",
126126+ "verification_uri_complete": "https://your-kaneo-instance.com/device?user_code=ABCD-1234",
127127+ "interval": 5,
128128+ "expires_in": 600
129129+}
130130+```
131131+132132+### Poll for a token
133133+134134+```bash
135135+curl -X POST https://your-kaneo-instance.com/api/auth/device/token \
136136+ -H "Content-Type: application/json" \
137137+ -d '{
138138+ "grant_type":"urn:ietf:params:oauth:grant-type:device_code",
139139+ "device_code":"dev_123",
140140+ "client_id":"your-app-id"
141141+ }'
142142+```
143143+144144+While waiting for approval, Kaneo may return:
145145+146146+- `authorization_pending`
147147+- `slow_down`
148148+- `invalid_client`
149149+- `expired_token`
150150+151151+Once approved, Kaneo returns an access token:
152152+153153+```json
154154+{
155155+ "access_token": "your-access-token",
156156+ "token_type": "Bearer"
157157+}
158158+```
159159+160160+### Use the returned token
161161+162162+```bash
163163+curl -X GET https://your-kaneo-instance.com/api/task?workspaceId=your-workspace-id \
164164+ -H "Authorization: Bearer your-access-token"
165165+```
166166+83167## Security Best Practices
8416885169- **Keep your API keys secret**: Never commit API keys to version control or share them publicly
···87171- **Rotate keys regularly**: Periodically create new API keys and revoke old ones
88172- **Limit key scope**: Only grant API keys to trusted applications and services
89173- **Monitor usage**: Regularly review your API keys and remove any that are no longer needed
174174+- **Allow only trusted device clients**: Keep `DEVICE_AUTH_CLIENT_IDS` limited to approved client IDs on self-hosted deployments
175175+- **Treat Bearer device tokens like secrets**: Do not print or log them unnecessarily in production clients
9017691177<Warning>
92178If you suspect your API key has been compromised, immediately revoke it in the API Keys section and create a new one.
···5050Name | Description |
5151--- | --- |
5252| `AUTH_SECRET` | The secret key for the JWT token. **Must be at least 32 characters long**, use a long, random value in production. Example: use `openssl rand -base64 32` to generate a secure key in Linux/macOS.
5353+| `DEVICE_AUTH_CLIENT_IDS` | Comma-separated list of allowed device authorization client IDs. Use this to permit trusted CLI or external app identifiers such as `kaneo-cli,my-desktop-app`. |
535454555556## Optional variables
···138139- If you enable Discord SSO, you need to set up the Discord application which is used to authenticate users in the [Discord Developer Portal](https://discord.com/developers/applications). See the [Discord SSO guide](/core/social-providers/discord).
139140- If you enable Custom OAuth/OIDC, you need to configure your identity provider with the appropriate redirect URI. See the [Custom OAuth/OIDC guide](/core/social-providers/custom-oauth).
140141- If you have enabled SMTP, your sign in will be done via email using a magic link.
142142+- If you want to allow CLI or external-app sign-in through device authorization, set `DEVICE_AUTH_CLIENT_IDS` to the trusted client IDs for your deployment.