Skip to content

Commit 558eb0a

Browse files
committed
updates
1 parent 2e85335 commit 558eb0a

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

livekit-api/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,26 @@ Access LiveKit server APIs and generate access tokens.
44

55
See https://docs.livekit.io/reference/server/server-apis for more information.
66

7+
## Authentication
8+
9+
Every request to the server APIs is authenticated. `LiveKitAPI` supports two modes:
10+
11+
- **API key & secret** — recommended for backend use. The SDK signs a short-lived token per request from your key and secret. Keep your API secret on the server; never ship it to a client.
12+
- **Access token** — for client-side use where the API secret must not be exposed. Pass a pre-signed [access token](https://docs.livekit.io/home/get-started/authentication/) that already carries the grants for the operations you'll perform; the SDK sends it verbatim.
13+
14+
```python
15+
from livekit import api
16+
17+
# API key & secret: set LIVEKIT_URL, LIVEKIT_API_KEY, and LIVEKIT_API_SECRET,
18+
# then construct with no arguments...
19+
lkapi = api.LiveKitAPI()
20+
21+
# ...or pass any of them explicitly to override the corresponding env var:
22+
lkapi = api.LiveKitAPI("https://my.livekit.host", api_key="api-key", api_secret="api-secret")
23+
24+
# Pre-signed access token (client-side): with LIVEKIT_URL set, pass just the token:
25+
lkapi = api.LiveKitAPI.with_token("a-pre-signed-token")
26+
```
27+
28+
The url and credentials fall back to the `LIVEKIT_URL`, `LIVEKIT_API_KEY`, `LIVEKIT_API_SECRET`, and `LIVEKIT_TOKEN` environment variables. Values you pass explicitly take precedence; the environment variables are used only as a fallback for arguments you omit — an ambient `LIVEKIT_TOKEN`, for example, won't override an explicitly-provided API key and secret.
29+

0 commit comments

Comments
 (0)