Skip to content

v5.17.0

Compare
Choose a tag to compare
@mrashed-dev mrashed-dev released this 04 Apr 19:20
· 18 commits to main since this release

This latest release of the Nylas Ruby SDK brings a few new additions.

Release Notes

Added

  • Added support for verifying webhook signatures (#413)
  • Added event.updated_at (#410)
  • Allow native authentication to return the full response like the exchange_code_for_token (#411)

Usage

Verifying webhook signatures

require 'sinatra'
require 'nylas'
require 'json'

set :port, 9000
NYLAS_CLIENT_SECRET = ENV['NYLAS_CLIENT_SECRET']

post '/' do
  content_type :json
  x_nylas_signature = request.env['HTTP_X_NYLAS_SIGNATURE']
  raw_body = request.body.read

  unless Nylas::Webhook::verify_webhook_signature(x_nylas_signature, raw_body, NYLAS_CLIENT_SECRET)
    status 403
    return { error: 'Invalid signature' }.to_json
  end

  body = JSON.parse(raw_body)
  puts "Webhook event received: #{JSON.pretty_generate(body)}"

  status 200
  { success: true }.to_json
end

run Sinatra::Application.run!

New Contributors 🎉