diff --git a/livekit-api/livekit/api/access_token.py b/livekit-api/livekit/api/access_token.py index d108c028..ef466eba 100644 --- a/livekit-api/livekit/api/access_token.py +++ b/livekit-api/livekit/api/access_token.py @@ -78,11 +78,8 @@ def __init__( api_key: Optional[str] = None, api_secret: Optional[str] = None, ) -> None: - if not api_key: - api_key = os.getenv("LIVEKIT_API_KEY") - - if not api_secret: - api_secret = os.getenv("LIVEKIT_API_SECRET") + api_key = api_key or os.getenv("LIVEKIT_API_KEY") + api_secret = api_secret or os.getenv("LIVEKIT_API_SECRET") if not api_key or not api_secret: raise ValueError("api_key and api_secret must be set") @@ -150,11 +147,8 @@ def __init__( *, leeway: datetime.timedelta = DEFAULT_LEEWAY, ) -> None: - if not api_key: - api_key = os.getenv("LIVEKIT_API_KEY") - - if not api_secret: - api_secret = os.getenv("LIVEKIT_API_SECRET") + api_key = api_key or os.getenv("LIVEKIT_API_KEY") + api_secret = api_secret or os.getenv("LIVEKIT_API_SECRET") if not api_key or not api_secret: raise ValueError("api_key and api_secret must be set") diff --git a/livekit-api/livekit/api/livekit_api.py b/livekit-api/livekit/api/livekit_api.py index 325d8d73..75b2822d 100644 --- a/livekit-api/livekit/api/livekit_api.py +++ b/livekit-api/livekit/api/livekit_api.py @@ -15,14 +15,9 @@ def __init__( *, timeout: float = 60, # 1 minutes by default ): - if not url: - url = os.getenv("LIVEKIT_URL") - - if not api_key: - api_key = os.getenv("LIVEKIT_API_KEY") - - if not api_secret: - api_secret = os.getenv("LIVEKIT_API_SECRET") + url = url or os.getenv("LIVEKIT_URL") + api_key = api_key or os.getenv("LIVEKIT_API_KEY") + api_secret = api_secret or os.getenv("LIVEKIT_API_SECRET") if not url: raise ValueError("url must be set")