from twitchAPI.helper import first
from twitchAPI.twitch import Twitch
from twitchAPI.oauth import UserAuthenticationStorageHelper
from twitchAPI.object.eventsub import ChannelFollowEvent
from twitchAPI.eventsub.websocket import EventSubWebsocket
from twitchAPI.type import AuthScope
import asyncio
APP_ID = ''
APP_SECRET = ''
TARGET_SCOPES = [AuthScope.MODERATOR_READ_FOLLOWERS]
async def on_follow(data: ChannelFollowEvent):
# наше событие состоялось, давайте что-то делать с полученными данными!
print(f'{data.event.user_name} now follows {data.event.broadcaster_user_name}!')
async def run():
twitch = await Twitch(APP_ID, APP_SECRET)
helper = UserAuthenticationStorageHelper(twitch, TARGET_SCOPES)
await helper.bind()
user = await first(twitch.get_users())
eventsub = EventSubWebsocket(twitch)
eventsub.start()
await eventsub.listen_channel_follow_v2('', '', on_follow)
try:
input('press Enter to shut down...')
except KeyboardInterrupt:
pass
finally:
# stopping both eventsub as well as gracefully closing the connection to the API
await eventsub.stop()
await twitch.close()
asyncio.run(run())
I have this code and I always get an error “twitchAPI.type.EventSubSubscriptionError: subscription missing proper authorization”
I took this code from the official documentation