Skip to content

Commit f65010e

Browse files
aryeilaclaude
andcommitted
Update e2ee example to use encryption kwarg and env vars
The deprecated `e2ee=` kwarg on RoomOptions has been replaced with `encryption=`. Also load SHARED_KEY, URL, and TOKEN from environment variables instead of hardcoding them, matching current docs patterns. Addresses DOCS-1278. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fbbe6f3 commit f65010e

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

examples/e2ee.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
import asyncio
22
import logging
3+
import os
34
from signal import SIGINT, SIGTERM
45

56
import numpy as np
67
from livekit import rtc
78

8-
URL = "ws://localhost:7880"
9-
TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE5MDY2MTMyODgsImlzcyI6IkFQSVRzRWZpZFpqclFvWSIsIm5hbWUiOiJuYXRpdmUiLCJuYmYiOjE2NzI2MTMyODgsInN1YiI6Im5hdGl2ZSIsInZpZGVvIjp7InJvb20iOiJ0ZXN0Iiwicm9vbUFkbWluIjp0cnVlLCJyb29tQ3JlYXRlIjp0cnVlLCJyb29tSm9pbiI6dHJ1ZSwicm9vbUxpc3QiOnRydWV9fQ.uSNIangMRu8jZD5mnRYoCHjcsQWCrJXgHCs0aNIgBFY" # noqa
9+
URL = os.environ.get("LIVEKIT_URL", "ws://localhost:7880")
10+
TOKEN = os.environ.get("LIVEKIT_TOKEN", "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE5MDY2MTMyODgsImlzcyI6IkFQSVRzRWZpZFpqclFvWSIsIm5hbWUiOiJuYXRpdmUiLCJuYmYiOjE2NzI2MTMyODgsInN1YiI6Im5hdGl2ZSIsInZpZGVvIjp7InJvb20iOiJ0ZXN0Iiwicm9vbUFkbWluIjp0cnVlLCJyb29tQ3JlYXRlIjp0cnVlLCJyb29tSm9pbiI6dHJ1ZSwicm9vbUxpc3QiOnRydWV9fQ.uSNIangMRu8jZD5mnRYoCHjcsQWCrJXgHCs0aNIgBFY") # noqa
1011

11-
# ("livekitrocks") this is our shared key, it must match the one used by your clients
12-
SHARED_KEY = b"livekitrocks"
12+
# This shared key must match the one used by your clients
13+
SHARED_KEY = os.environ.get("E2EE_SHARED_KEY", "livekitrocks").encode()
1314

1415
WIDTH, HEIGHT = 1280, 720
1516

@@ -106,7 +107,7 @@ def on_e2ee_state_changed(participant: rtc.Participant, state: rtc.EncryptionSta
106107
e2ee_options.key_provider_options.shared_key = SHARED_KEY
107108

108109
await room.connect(
109-
URL, TOKEN, options=rtc.RoomOptions(auto_subscribe=True, e2ee=e2ee_options)
110+
URL, TOKEN, options=rtc.RoomOptions(auto_subscribe=True, encryption=e2ee_options)
110111
)
111112

112113
logging.info("connected to room %s", room.name)

0 commit comments

Comments
 (0)