Skip to content

Instantly share code, notes, and snippets.

@thoughtspeed7
Created January 5, 2018 13:27
Show Gist options
  • Save thoughtspeed7/2b8b92677cceeae193c0e3f3c4ec14fd to your computer and use it in GitHub Desktop.
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
// 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