POST subscribe webhook


#1

Hello, I can’t seem to make my post request to subscribe to a webhook work. I get “Unauthorized” error.
I’ve tried with access_token, client_id and app_token.

Does anyone have any idea?
I have channel:read:subscriptions+user:edit as scope on access_token.

const response = await axios
.post(https://api.twitch.tv/helix/webhooks/hub, {
body: {
“hub.callback”: “http://localhost:3000/twitch/auth”,
“hub.mode”: “subscribe”,
“hub.topic”: “https://api.twitch.tv/helix/streams?user_id=5678”,
“hub.lease_seconds”: 60,
},
headers: {
Authorization: "Bearer " + TWITCH_ACCESS_TOKEN,
“Client-ID”: TWITCH_CLIENT_ID,
},
})


#2

You can’t use localhost as a callback URL. Twitch has to be able to send requests to your callback, so any localhost URL will never be internet accessible.


#3

Ah oke, but is that what’s causing the “Unauthorized” error?

Is it the same callback as when getting the access/app tokens because those worked on localhost.

Planing on fixing an accessible server soon.


#4

The callback can be whatever you want it to be as long as it’s internet accessible (and HTTPS for certain topics), it doesn’t have to be the same as your Auth process callback, and while that callback will work for you because you can access your localhost, no one else can meaning I can’t go through your auth process, and Twitch can’t send Webhook notifications there.

As for why you’re getting an Unauthorized error I’m not sure as the Stream Change topic doesn’t require any special Auth scope. Try see if you still get that error when using a callback URL that’s actually valid to be used for webhooks.


#5

Ah oke, I only used localhost development but will fix a valid callback URL and try again. Thanks for the help.