Skip to content

Commit

Permalink
Ensure the user passes a valid combination of client_id/client_secret…
Browse files Browse the repository at this point in the history
… and/or token before login.
  • Loading branch information
EvieePy committed Jan 7, 2025
1 parent ebaa1c2 commit d7e9e3b
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions twitchio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d7e9e3b

Please sign in to comment.