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,
'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);
} else {
console.log('Got ' + r.statusCode + ' to ' + channel);
console.log(b);
}
});
You did change the channelID in your signedJWT and the URL you post to right?
Check the example ->
The ChannelID is in the signedJWT and in the URL you POST to.
Seems you shouldn’t get a 204 if the JWT is valid but doesn’t match the ChannelID you are POSTing to.
You sent a valid JWT for the wrong channel?