From d7e9e3b4d01f61c9b352dea883aa57095251bda8 Mon Sep 17 00:00:00 2001 From: EvieePy <29671945+EvieePy@users.noreply.github.com> Date: Tue, 7 Jan 2025 13:38:28 +1000 Subject: [PATCH] Ensure the user passes a valid combination of client_id/client_secret and/or token before login. --- twitchio/client.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/twitchio/client.py b/twitchio/client.py index a07b2c82..18a7137e 100644 --- a/twitchio/client.py +++ b/twitchio/client.py @@ -310,6 +310,12 @@ async def login(self, *, token: str | None = None, load_tokens: bool = True, sav self._login_called = True self._save_tokens = save_tokens + if not self._http.client_id: + raise RuntimeError('Expected a valid "client_id", instead received: %s', self._http.client_id) + + if not token and not self._http.client_secret: + raise RuntimeError('Expected a valid "client_secret", instead received: %s', self._http.client_secret) + if not token: payload: ClientCredentialsPayload = await self._http.client_credentials_token() validated: ValidateTokenPayload = await self._http.validate_token(payload.access_token)