Skip to content

Client created with from_client_credentials doesn't work #371

@iarspider

Description

@iarspider

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
  1. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions