PythonistaGuild / TwitchIO

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

replace_tags() always returns 403: Forbidden 'Failed to fulfil request (403).' #221

Closed eelcohn closed 2 years ago

eelcohn commented 3 years ago

When I try to replace the stream tags, the replace_tags() function always returns 403: Forbidden.

This is the code I use:

class TwitchAPI(twitchio.ext.commands.Bot):

    def __init__(self):

        super().__init__(
            token = 'abcdefghijklmnopqrstuvwxyzABCD',
            prefix = '!',
            initial_channels = ['xxxxxxxxxx']
        )

    async def event_ready(self):
        print(f'Logged in as | {self.nick}')

        channel = await self.fetch_channel(self.nick)
        if channel is not None:
            await channel.user.replace_tags(
                token = 'abcdefghijklmnopqrstuvwxyzABCD',
                tags = [
                    'c553e849-7019-479b-a14d-a78cd3462e9a',
                    '55afc9b3-67c9-46a0-aaad-d2fc65202f1b',
                    '2068d8f3-269c-43f2-9a00-82aeb3f0a3b8',
                    'c5247b10-deec-4d7a-84a5-db6a75cb5908',
                    'd81d54c8-d705-4df6-aaf0-01d715c1dbcc'
                ],
            )

According to the documentation the token should have the channel:manage:broadcast scope. When I check my token using the https://id.twitch.tv/oauth2/validate endpoint, I get the following response:

{
  "client_id": "abcdefghijklmnopqrstuvwxyzABCD",
  "login": "xxxxxxxxxx",
  "scopes": [
    "channel:manage:broadcast",
    "channel:moderate",
    "channel_editor",
    "chat:edit",
    "chat:read",
    "whispers:edit",
    "whispers:read"
  ],
  "user_id": "123456789",
  "expires_in": 4420120
}

AFAIK the token therefore has the correct scope. Any thoughts what's going wrong here?

chillymosh commented 3 years ago

By the looks of it you are self botting rather than using a separate Twitch account for your bot? I recommend you join the Discord for further support as more people are likely to see your message to respond.