0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

PubSubHubbub Hub `challenge mismatch` を解決

Posted at

問題

youtube apiのpush notification、詳細は↓
https://developers.google.com/youtube/v3/guides/push_notifications

これのwebhookを実装した後、↓のページでsubscribeしようとすると
https://pubsubhubbub.appspot.com/subscribe
challenge mismatchとエラーが出ます。

解決

firebase cloud functionを利用しているが、node.jsのexpressでも通用すると思います。

exports.youtubeWebhook = functions
    .region("asia-northeast1")
    .https.onRequest((req, res) => {
        // challengeに回答する。mismatchを解消
        if (req.query['hub.challenge']) {
            res.set('Content-Type', 'text/plain');
            res.status(200).send(req.query['hub.challenge']);
            return;
        }
        // ここからxmlを受け取って、ビジネスロジックを実行
        ...
    });
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?