PythonistaGuild / TwitchIO

An Async Bot/API wrapper for Twitch made in Python.
https://twitchio.dev
MIT License
791 stars 163 forks source link

Client created with from_client_credentials doesn't work #371

Closed iarspider closed 1 year ago

iarspider commented 1 year ago

I was trying to get Client to auto-refresh the token, but stumbled upon a few issues:

  1. Client.from_client_credentials(...).start() raises AuthenticationError. The actual exception is raised inside self._client._http.validate, which can't handle the situation when both token and self.token are None. The fix is easy:

    async def validate(self: twitchio.http.TwitchHTTP, *, token: str = None) -> dict:
    if not token:
    # add these two lines:
        if self.token is None:
            await self._generate_login()
        token = self.token
  2. But even fixing that is not enough: for application tokens (generated by _generate_login) the response of /oauth2/validate does not contain login or user_id - which WSConnection._connect(...) expects.

github-actions[bot] commented 1 year ago

Hello! Thanks for the issue. If this is a general help question, for a faster response consider joining the official Discord Server

Else if you have an issue with the library please wait for someone to help you here.

IAmTomahawkx commented 1 year ago

This is expected behaviour. You cannot log into chat with a client credential token