Skip to content

Commit 2018ab8

Browse files
aryeilaclaude
andauthored
Update e2ee example to use encryption kwarg and env vars (#631)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent fbbe6f3 commit 2018ab8

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

examples/e2ee.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
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(
11+
"LIVEKIT_TOKEN",
12+
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE5MDY2MTMyODgsImlzcyI6IkFQSVRzRWZpZFpqclFvWSIsIm5hbWUiOiJuYXRpdmUiLCJuYmYiOjE2NzI2MTMyODgsInN1YiI6Im5hdGl2ZSIsInZpZGVvIjp7InJvb20iOiJ0ZXN0Iiwicm9vbUFkbWluIjp0cnVlLCJyb29tQ3JlYXRlIjp0cnVlLCJyb29tSm9pbiI6dHJ1ZSwicm9vbUxpc3QiOnRydWV9fQ.uSNIangMRu8jZD5mnRYoCHjcsQWCrJXgHCs0aNIgBFY",
13+
) # noqa
1014

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

1418
WIDTH, HEIGHT = 1280, 720
1519

@@ -106,7 +110,7 @@ def on_e2ee_state_changed(participant: rtc.Participant, state: rtc.EncryptionSta
106110
e2ee_options.key_provider_options.shared_key = SHARED_KEY
107111

108112
await room.connect(
109-
URL, TOKEN, options=rtc.RoomOptions(auto_subscribe=True, e2ee=e2ee_options)
113+
URL, TOKEN, options=rtc.RoomOptions(auto_subscribe=True, encryption=e2ee_options)
110114
)
111115

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

0 commit comments

Comments
 (0)