After authorising and redirecting back to my app, I get back a code (for redaction purposes, call it XYZ) (along with the state to check UUID etc etc) - all good. This is where my browser comes back to:
Open a terminal window and enter the following cURL POST command (you’ll need cURL installed on your computer). Replace the placeholder strings and the authorization code with your values.
example
curl -X POST 'https://id.twitch.tv/oauth2/token' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'client_id=<your client id goes here>&client_secret=<your client secret goes here>&code=17038swieks1jh1hwcdr36hekyui&grant_type=authorization_code&redirect_uri=http://localhost:3000'
That’ll return you an access token. after code to token exchange is complete
Ah, missed that step somehow. Thanks. What’s the normal life cycle for the token, should I generate one for every transaction or store the token for future use?
But note this example uses implicit auth rather than code flow auth. But the steps are the same, do something to get a user token, then use the user token against the users API
I’ve sort of made some progress as I was trying to subscribe to chat messages so they call a webhook, which I think needs the kind of token I generated anyway.
But something’s not quite right. If I sign in as a different user and message the chat in my channel, the messages don’t appear. The user is email-verified, there’s nothing in moderation or anything filtering it out as far as I can tell, I can see the user is watching, but no messages come through… and when I click the user it shows the attached. Not sure why I’m having all these issues?!
Essentially I’m trying to subscribe to all chat messages, so that every message posted in the channel is forwarded to a webhook.
The sub seemed to work, but when I didn’t get any messages coming through to my endpoint, I wondered whether it was because I don’t receive messages from my own user ID. Hence trying another account - so now I’m thinking if those messages don’t even show in the chat window on my channel, it’s not surprising I’m not getting them via my endpoint.
Ah, so there’s no way to get all messages relayed via a webhook or some other method?
No worries if so… I guess I can embed the chat window - but why are the messages from my ‘other’ user not even appearing my chat window? I’ve even tried removing the requirement for email verification. But not a peep from anything, it still insists that my test user has yet to post anything.
Could it be something I’ve broken with my sub attempts? I’ve just registered a new user on a completely different computer / IP, and nothing from that either. It’s like there’s a permission to stop anyone but the channel owner posting. Very odd.
Oddly, my Mac crashed shortly after, and since a reboot it’s fine. Some process looking after websockets must have hung or something I guess. Anyway, thanks for all your help Barry!