Closed Jawnnypoo closed 6 years ago
Looks like currently they have only 1 event, so this provider should be nice and small in the begining. I am looking to ways to test this, but for now I'll leave this link here also: https://dev.twitch.tv/docs/api/webhooks-reference
Okay so twitch integration will be a bit tricky. The first obstacle is that the twitch payload only sends the user id of the new follower. That's not enough to construct an embed, so we need to follow up with a request to twitch's api to get the display name of said user. That's all good since we have the async provider system, however a Client-ID
is required to make that call.
The second thing that's tricky is that the twitch hook will not just accept a callback_url
, it requires validation from the host itself. What it does is sends a GET request to the specified callback url with a header hub.challenge.
The response of the callback server must be the challenge token provided by the GET along with a status code of 202. This isn't too hard to do, it's just more than is required for all of the providers that are currently supported.
Back to the issue of the client id. Skyhook would likely need its own Client-ID to perform the interactions with the Twitch API as mentioned. This id could not just be committed though, there would need to be some sort of private server-side config.
The last issue is that since twitch requires a response from the callback url, I can't really test this locally since I'm at university and the ports are locked down. I can't even setup the webhook through requestb.in due to the extra security layer in place. Any way to get around this?
What's nice about glitch.com is that we can add things to the .env variable and it will keep it secret from everyone else. So, I can create an app within Twitch to allow us to get a client id.
For yourself, could you potentially get a VPN server set up? Super lame that the university would block something like Twitch...
Well it hasn't blocked twitch, it's just that I can't run the server locally because their are no forwarded ports. If there is a way to accept payloads from my IP via a vpn, I would love to set that up. In the meantime I was able to setup a remote copy on https://cloudno.de/, however the twitch webhooks havent been working for me.. not sure if I'm doing something wrong. When it sends the validation I return the code it gives with a status code of 202 and get no further response from Twitch. I then tried triggering the hook by gaining a follower and no post request was sent. Not sure what's up with it.
Would you like to put what you have so far in a branch and initiate a PR so that I can do some testing as well?
Posted about it on twitch dev forums https://discuss.dev.twitch.tv/t/help-with-webhooks/12618
Possible issue with client id rate limits
https://discuss.dev.twitch.tv/t/helix-api-clientid-limit/12469
Edit, I got it to work - gonna write up a proper PR because the branch is full of a lot of testing commits.
@dscalzi Do you happen to have this PR somewhere? Would love to see it
Havent been able to work on it, plus I'm still trying to figure out how this would work with a huge rate limit.
I think that this is just going to be a no go for this project. There are other tools out there for Twitch to Discord integration and this would be a huge effort.
I think this will be a big request, if Discord themselves do not support it: https://dev.twitch.tv/docs/api/webhooks-guide