Created
January 5, 2018 13:27
-
-
Save thoughtspeed7/2b8b92677cceeae193c0e3f3c4ec14fd to your computer and use it in GitHub Desktop.
X-Hub-Signature Verification on Google Cloud Functions for Facebook Graph API Webhooks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// om namah shivay | |
// environment variables | |
const FB_APP_SECRET = 'your facebook app secret'; | |
// requires | |
const crypto = require('crypto'); | |
const verifyXHubSignature = req => { | |
const digest = crypto | |
.createHmac('sha1', FB_APP_SECRET) | |
.update(req.rawBody) | |
.digest('hex'); | |
return req.headers['x-hub-signature'] === `sha1=${digest}`; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment