Skip to content

Commit c84202e

Browse files
committed
fix
1 parent b08fc36 commit c84202e

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

livekit-api/livekit/api/livekit_api.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,15 @@ def __init__(
4949
session: aiohttp.ClientSession instance to use for requests, if not provided, a new one will be created
5050
"""
5151
url = url or os.getenv("LIVEKIT_URL")
52-
token = token or os.getenv("LIVEKIT_TOKEN")
53-
api_key = api_key or os.getenv("LIVEKIT_API_KEY")
54-
api_secret = api_secret or os.getenv("LIVEKIT_API_SECRET")
52+
53+
# Only fall back to environment credentials when none were provided
54+
# explicitly, so an ambient LIVEKIT_TOKEN can't silently override an
55+
# explicit api_key/secret (or vice versa).
56+
if not token and not api_key and not api_secret:
57+
token = os.getenv("LIVEKIT_TOKEN")
58+
if not token and not api_key and not api_secret:
59+
api_key = os.getenv("LIVEKIT_API_KEY")
60+
api_secret = os.getenv("LIVEKIT_API_SECRET")
5561

5662
if not url:
5763
raise ValueError("url must be set")

0 commit comments

Comments
 (0)