Webhooks subscribe accepted, but no received events

i tried webhooks subscribe ‘https://api.twitch.tv/helix/subscriptions/events?broadcaster_id=1234567890&first=1

i can get accept message, but no received events.

my code is->

	var clientID = 'myID'
	var contentType = 'application/json'
	var postURI = 'https://api.twitch.tv/helix/webhooks/hub'
	var secret = 'secretvalue'
	var options =
		{
			headers: {
				'Client-ID': clientID,
				'Content-Type': contentType,
				'Authorization':'Bearer '+'myToken'
			},
			uri: postURI,
			method: 'POST',
			json: {
				"hub.mode":"subscribe",
				"hub.topic":"https://api.twitch.tv/helix/subscriptions/events?broadcaster_id=123456789&first=1",
				"hub.callback":"myCallback",
				"hub.lease_seconds":864000,
				"hub.secret":secret
			}
		}
	request(options,function(e,r,b) {
		console.log('Req status code : ' + r.statusCode);
		if(r.statusCode === 202) {
			console.log(r.statusMessage)
		} else {
			console.log;
		}
	});

route.post('/send',function (req,res) {
	console.log('post');
	req.on('data',function(chunk) {
		var data = '';
		data += chunk.toString();
		var rst = JSON.parse(data);
		console.log(rst);
	});
	res.status(200).send('done');
});

route.get('/send',function (req,res) {
	console.log('get');
	res.status(200).send(req.query['hub.challenge']);
});

thank you.

I don’t see anything obviously wrong with your code.

I’m assuming you are actually setting this up for a “real” broadcaster_id and thus with a “real” oAuth token.

The only other thing that is missing is the fact that an oAuth token is only valid for four hours so the lease time is overridden from 10 days, in your case, to four hours.

You can use the Webhook subscription status API to check for this and active webhooks

thx for the reply.

I checked “hub.mode” and “hub.reason” is

“denied” and “unauthorized”.

I got Token from “OAuth Authorization Code Flow” and “OAuth Client Credentials Flow”.
and I requested webhooks.
but I received message 1) “Auth is required”. 2) Accepted, but hub.mode, hub.reason is “denied”, “unauthorized”

Which I get(use) Auth Token?

thx.

You need to use the Authorization Code Flow.

The Subscriptions Event topic requires the channel:read:subscriptions scope, so you need the streamer to go through your auth process to grant you the token to see their subscription events.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.