Youtube PubSubHubBub Integration

3.3k Views Asked by At

Been stuck on this integration problem for hours now. I am trying to subscribe to a youtube channel updates using https://pubsubhubbub.appspot.com/subscribe.

Subscription Request

And my server is setup to respond with:

Server Response

But when I press DO IT, I always get back the error saying Challenge mismatch.

I am unsure which parameter I am missing to set.

2

There are 2 best solutions below

1
Vabs On BEST ANSWER

The intended response is not a static value as hub_challenge. It should return back the hub.challenge value which is received in query parameters when GET request is sent to the callback url.

More Information

The request will be something like /notifications?hub.topic=https://www.youtube.com/xml/feeds/videos.xml%3Fchannel_id%3DUCn0QU5ZOaVnEf7LkdyPF9kQ&hub.challenge=216582865281647747&hub.mode=subscribe&hub.lease_seconds=432000"

The response of should be the value hub.challenge (216582865281647747)

0
timraybould On

Assuming you're using (either directly or indirectly) https://www.npmjs.com/package/body-parser, you could do something like this:

const responseText = request.query['hub.challenge'] || "no challenge" response.send(responseText)

But even if not that exact syntax, figure out how to log the query parameters that the hub adds when hitting the callback URL. There you will see the value for 'hub.challenge' which you can then send back in the response.