Webhook with Firebase Not Getting Verify

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.

Don’t use your Twitch Secret here.
The Hub.Secret can be anything you want it to be, but it should not be the Secret for this ClientID. The secret is for you to use to test the payload to be valid from Twitch, so you can use any random string, but it shouldn’t be your Twitch Secret.

Secret used to sign notification payloads. The X-Hub-Signature header is generated by sha256(secret, notification_bytes) . We strongly encourage you to use this, so your application can verify that notifications are genuine.

It’s basically the same thing as “state” in oAuth loops.

As to your actual problem no idea, are you sure the endpoint, in hub.callback is correct? And if you are setting http it’s not dropping/failing when it force upgrades to https? Try the same code not using firebase if you can.

Thanks for the response!
I should have clarified about that twitch.secret, its just an import of a string ‘goodiegumdrops’ lol.

I’m pretty sure the hub.callback is correct, and it’s all https. The hub.callback goes to ‘< web address >/livestats-update’ while in the GET and POST listeners are ‘/livestats-update’.

I think you’re right, it’s gotta be something with the firebase functions. Looking into it more, thanks!

How you tried calling the callback yourself to see if it’s actually logging?

Edit: figured it out below

If anyone else is using firebase, here’s the best way I found:

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