You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It appears as though pyTwithchAPI is not actually registering subscriptions with Twitch.
Description:
I'm trying to setup the most basic event-handler service which is almost a carbon copy of the example code from the ReadTheDocs:
#!/usr/bin/env pythonimportosimportasyncioimportloggingimportjsonfromtwitchAPI.helperimportfirstfromtwitchAPI.twitchimportTwitchfromtwitchAPI.oauthimportAuthScope, UserAuthenticatorfromtwitchAPI.eventsub.webhookimportEventSubWebhookfromtwitchAPI.eventsub.websocketimportEventSubWebsocketfromtwitchAPI.object.eventsubimportChannelSubscriptionGiftEventAPP_ID=os.getenv("OMT_CLIENT_ID")
APP_SECRET=os.getenv("OMT_CLIENT_SECRET")
TARGET_USERNAME="the_ivo_robotnic"CALLBACK_URL="https://[redacted]/"USER_TOKEN_PATH=f'{os.getcwd()}/user_token.json'CALLBACK_PORT=7071TARGET_SCOPES= [AuthScope.USER_READ_SUBSCRIPTIONS]
CALLBACK_TIMEOUT=3# Seconds# Configure loggerlogging.basicConfig(level=logging.DEBUG)
LOG=logging.getLogger(__name__)
asyncdefon_subscribe(data: ChannelSubscriptionGiftEvent) ->None:
e=data.event# Truncate the event objectLOG.info(f"{e.user_name} gifted {e.total}{e.total}x {e.tier} subs!")
asyncdefmain():
# Create and authenticate Twitch API Clienttwitch=awaitTwitch(APP_ID, APP_SECRET)
user=awaitfirst(twitch.get_users(logins=TARGET_USERNAME))
auth=UserAuthenticator(twitch, TARGET_SCOPES)
access_token=awaitauth.authenticate()
withopen(USER_TOKEN_PATH, "w+") asfile:
json.dump(access_token, file)
LOG.debug(f'Wrote cached user token to -> {USER_TOKEN_PATH}')
# Create the EventSub Mangereventsub=EventSubWebhook(CALLBACK_URL, CALLBACK_PORT, twitch=twitch)
eventsub.wait_for_subscription_confirm=Trueeventsub.wait_for_subscription_confirm_timeout=CALLBACK_TIMEOUT# Start the EventSub Clienteventsub.start()
# Unscrubscribe from everything to clear artifactsawaiteventsub.unsubscribe_all()
# Listen for EventsLOG.debug("Beginning subscriptions... ")
awaiteventsub.listen_channel_subscription_gift(user.id, on_subscribe)
LOG.debug("Done!")
try:
# Block on user input for shutdowninput("Press any key to shut down...")
finally:
awaiteventsub.stop()
awaittwitch.close()
asyncio.run(main())
STDOUT is:
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:twitchAPI.twitch:generating fresh app token
DEBUG:twitchAPI.twitch:making GET request to https://api.twitch.tv/helix/users?login=the_ivo_robotnic
DEBUG:asyncio:Using selector: EpollSelector
INFO:twitchAPI.oauth:running oauth Webserver
DEBUG:twitchAPI.oauth:got callback with state 20944040-7b07-48f5-9a91-b7d2caf7a759
INFO:aiohttp.access:127.0.0.1 [08/May/2024:19:22:21 -0700] "GET /?code=9csyzkrrs5m2yclnqt2388ci9h59ms&scope=user%3Aread%3Asubscriptions&state=20944040-7b07-48f5-9a91-b7d2caf7a759 HTTP/1.1" 200 452 "-""Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0"
INFO:aiohttp.access:127.0.0.1 [08/May/2024:19:22:22 -0700] "GET /favicon.ico HTTP/1.1" 404 173 "http://localhost:17563/?code=9csyzkrrs5m2yclnqt2388ci9h59ms&scope=user%3Aread%3Asubscriptions&state=20944040-7b07-48f5-9a91-b7d2caf7a759""Mozilla/5.0 (X11; Linux x86_64; rv:125.0) Gecko/20100101 Firefox/125.0"
INFO:twitchAPI.oauth:shutting down oauth Webserver
DEBUG:__main__:Wrote cached user token to -> /home/ivo/repos/shift/obs-media-triggers/src/user_token.json
DEBUG:asyncio:Using selector: EpollSelector
INFO:twitchAPI.eventsub.webhook:started twitch API event sub on port 7071
DEBUG:twitchAPI.twitch:making GET request to https://api.twitch.tv/helix/eventsub/subscriptions
DEBUG:__main__:Beginning subscriptions...
DEBUG:twitchAPI.eventsub.webhook:subscribe to channel.subscription.gift version 1 with condition {'broadcaster_user_id': '128300706'}
DEBUG:twitchAPI.eventsub.webhook:subscription for channel.subscription.gift version 1 with condition {'broadcaster_user_id': '128300706'} has id 7439eda8-095f-403c-b5d8-ff952aa83b15
DEBUG:twitchAPI.eventsub.webhook:received challenge for subscription 7439eda8-095f-403c-b5d8-ff952aa83b15
INFO:aiohttp.access:10.8.0.1 [08/May/2024:19:22:26 -0700] "POST /callback HTTP/1.1" 200 195 "-""Go-http-client/1.1"
DEBUG:__main__:Done!
Press any key to shut down...
So everything appears to be working... On the surface, but When running:
Problem Statement:
It appears as though
pyTwithchAPI
is not actually registering subscriptions with Twitch.Description:
I'm trying to setup the most basic event-handler service which is almost a carbon copy of the example code from the ReadTheDocs:
STDOUT is:
So everything appears to be working... On the surface, but When running:
clear && twitch event -F http://localhost:7071/callback trigger channel.subscribe -f dingus
It results in:
And when separately checking with cURL my active subscriptions- while the service is still running:
It responds with essentially no active subscriptions:
So it seems as though the subscriptions are not being fully registered, and there's nothing jumping out at me as to why.
Any ideas as to what I might be missing and/or what's going wrong?
I appreciate the help,
Ivo R.
The text was updated successfully, but these errors were encountered: