Helix responds with 401
Schrotty opened this issue · 5 comments
Schrotty commented
Hello there, I tried to fetch the moderators of a channel but got a 401.
self.twitch_helix = twitch.Helix(client_id=f'{os.getenv("TWITCH.CLIENTID")}', use_cache=True, client_secret=f'{os.getenv("TWITCH.SECRET")}')
identifier: str = self.twitch_helix.user("schrottler").id
mods = self.twitch_helix.api.get("moderation/moderators", {"broadcaster_id": identifier}).get()
Both ClientID and ClientSecret are set. Any idea?
Or is this type of request not supported?
MPeti1 commented
I'm hitting the same problem, could you tell what was your solution?
Schrotty commented
Oh, sorry, no solution. I used another library in the end.
MPeti1 commented
oh, thank you. it's bad news, because afaik other libraries don't have support for the stream chat :/
MPeti1 commented
I think I found it out. writing here so others may find this.
It seems the Helix class does not obtain an oauth token for itself. Twitch Chat Downloader obtains the oauth token by itself, using this snippet:
oauth_token = requests.post(f"https://id.twitch.tv/oauth2/token"
f"?client_id={client_id}"
f"&client_secret={client_secret}"
f"&grant_type=client_credentials").json()['access_token']
and then uses this contructor:
helix = twitch.Helix(client_id=client_id, bearer_token=oauth_token, use_cache=True)
MPeti1 commented
but well, in the end I get the same random errors and slowness as I had with TCD :/