var tokenPayload = {
exp: Math.floor(new Date().getTime() / 1000) + 60,
channel_id: ''+channel,
role: 'external',
pubsub_perms: {
send: [
'broadcast'
]
}
}
let signedJwt = jwt.sign(tokenPayload, secret);
request.post({
url: 'https://api.twitch.tv/v5/extensions/message/' + channel,
headers: {
Accept: 'application/vnd.twitchtv.v5+json',
Authorization: 'Bearer ' + signedJwt,
'Client-ID': client_id,
'Content-Type': 'application/json'
},
body: JSON.stringify({
message: payload,
content_type: 'application/json',
targets: ['broadcast']
}),
gzip: true
}, function(e, r, b) {
if (e) {
console.log(e);
} else if (r.statusCode == 204) {
console.log('Ok to ' + channel + ' with ' + mode + ' Left ' + stack[channel].length);
} else {
console.log('Got ' + r.statusCode + ' to ' + channel + ' with ' + mode);
console.log(b);
}
});
Does this help?
Response is 204 if all good.