So I’m trying to setup my webhooks, but I’m currently not getting a challenge to verify the subscription after I receive a 202 status. Right now I’m not sure if this is something to do my firebase/express code or if it’s fetch that’s missing something. I’ve read all the other posts about webhooks here, but most are getting the challenge back and I’m stumped.
webhook post:
await fetch('https://api.twitch.tv/helix/webhooks/hub', {
'method': 'POST',
'headers': {
'Content-Type': 'application/json',
'Client-ID': <twitch.clientId>
},
body: JSON.stringify({
'hub.mode': 'subscribe',
'hub.lease_seconds': '864000',
'hub.callback': '<endpoint>',
'hub.topic': `https://api.twitch.tv/helix/streams?user_id=${<twitchID>}`,
'hub.secret': <twitch.secret>
})
})
.then((res) => console.log(res.status) // Returns 202 )
//rest of res:
// body: ReadableStream
// bodyUsed: false
// headers: Headers {}
// ok: true
// redirected: false
// status: 202
// statusText: ""
// type: "cors"
url: "https://api.twitch.tv/helix/webhooks/hub"
.catch(err =>
console.error('Webhook Creation Error: ', err)
);
Then I have my functions below to listen to that endpoint above but the firebase console is telling me neither have been invoked at all.
firbase hosted/express functions:
const functions = require('firebase-functions');
const express = require('express');
const cors = require('cors');
const app = express();
app.use(cors({ origin: true }));
app.get('/<endpoint route>', (req, res) => {
console.log('req: ', req);
console.log('res: ', res);
res.end("Received GET");
});
app.post('/<endpoint route>', (req, res) => {
console.log('req: ', req);
console.log('res: ', res);
res.end("Received POST");
});
exports.widgets = functions.https.onRequest(app);
If there is anymore information that I can give to help you help me let me know.