I was using the Webhook Mechanism to register for HypeTrain related events and faced an intriguing mystery.
I have two different registrations for Webhooks. One allows me to subscribe to follower events. I always ask for the maximum time, i.e. 10 days, i.e. 864000 seconds in order to call the re-registration once a week.
For the event of followers, I obtain after verification, a good expiration date (Example we are the 1st, the expiration runs until the 11th). This is not the case at all with HypeTrain events, registration is indicated as valid … 10 minutes.
Registration is done at the same time using the same code, with the same parameters, and the same acces_token. Is it normal that the expiration of this topic is so short? Do I have to re-register every 10 minutes?
Thank you in advance
Any topic that requires a User Access Token will be limited to the whatever is the shorter of the token expiration or the requested lease time.
If the User Token only has 10 minutes until it expires, the subscription must also expire after 10 minutes, even if you request a longer lease time.
Alternatively I suggest using EventSub https://dev.twitch.tv/docs/eventsub as that uses App Access Tokens, and the subscriptions don’t expire (unless the user revokes permission for your app, which will kill the subscription).
First of all thank you for your reply,
I have indeed just noticed that this webhook expires on the same date as my acces_token, it is very annoying for the moment indeed.
To overcome this problem, I plan to force the obtaining of a new access_token each time my cron task is called which registers me for events.
I know I have to look at EventSub but I haven’t understood how it works yet, I haven’t understood why the use of “websockets” was mentioned when we are filling in URLs callback.
Currently EventSub is strictly equal to the classic Webhook in terms of registration / list process, etc. right?
EventSub is very similar to Webhooks, but it doesn’t follow the Websub spec which gives it more freedom than Webhooks.
Websockets are mentioned because while EventSub currently only supports HTTPS callbacks, it will eventually be possible to subscribe to events and have Twitch send notifications back through other transport methods, such as Websockets, or SNS, etc…
One of the key changes for the issue you’re facing though is that EventSub uses App tokens entirely, and the subscriptions aren’t limited by token life, meaning that once you subscribe to a topic you’ll stay subscribed until you cancel it or you no longer have authorization for that topic.
I have a doubt about what you just told me because I notice that for the event https://dev.twitch.tv/docs/eventsub/eventsub-subscription-types#channelhype_trainprogress it is necessary to have the channel:read:hype_train scope.
But you know that this is impossible with an App Access Token.
How could an App Access Token have access to a user’s Scope ???
Yes, you still need the user to grant permission to your app for the scopes required, but EventSub doesn’t require the User Token from that OAuth process.
With EventSub you use an App Access Token, and on Twitch’s end they check if your app has been granted the scopes required by the user for the topic you’re attempting to subscribe to. Your app could generate an App Access Token, and use that 1 token for subscribing to every EventSub topic that you have access to (within the max subscriptions limit), from any user that has granted your app access to those topics.
So… how and user can grant scope to my app ? with oauth system in other side ? if user grant one time this scope, twitch save this state and use it when i’m asking with app access token ?
The user grants permission the same way they always have, through your apps OAuth flow as documented here: https://dev.twitch.tv/docs/authentication/getting-tokens-oauth
Once the user goes through the Implicit or Auth Code flow that user is connected to your app, that is nothing new that has always happened. The only difference with EventSub is that Twitch checks your app for the connection/scopes required for what topics you’re subscribing too, rather than using the token and checking for validity/scopes from that.
You can see all the apps that you’re connected to here: https://www.twitch.tv/settings/connections
All of those apps that are listed there will be able to use their App token to subscribe to EventSub topics that you’ve granted them permission for.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.