Skip to content

Instantly share code, notes, and snippets.

@khamidou
Last active September 28, 2021 13:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save khamidou/1df27edb0f7fc08d47f0 to your computer and use it in GitHub Desktop.
Save khamidou/1df27edb0f7fc08d47f0 to your computer and use it in GitHub Desktop.
Verifying Nylas webhooks using Ruby
require 'openssl'
# verify_webhook: check that a webhook was sent by a Nylas server.
# params:
# - request: the request object you get from Rails,
# - nylas_app_secret: your app secret.
def verify_webhook(request, nylas_app_secret)
digest = OpenSSL::Digest.new('sha256')
data = request.body.read
digest = OpenSSL::HMAC.hexdigest(digest, nylas_app_secret, data)
digest == request.headers['X-Nylas-Signature']
@elialbert
Copy link

still works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment