Only show these results:

[2023-04-04] Nylas Python SDK v5.14.0

Categories: Sdks Python

The Nylas Python SDK v5.14.0 has been released!

This release brings new features for webhooks and the token-info endpoint.

Added

  • Added support for verifying webhook signatures (#257)
  • Added optional parameter for token-info endpoint (#256)

Verifying webhook signatures with the Nylas Python SDK

from flask import Flask, request, jsonify
from nylas import APIClient, Webhook
import os
import json

app = Flask(__name__)
port = 9000
NYLAS_CLIENT_SECRET = os.environ.get("NYLAS_CLIENT_SECRET")

@app.route("/", methods=["POST"])
def webhook_callback():
signature = request.headers.get("X-Nylas-Signature")
request_data = json.dumps(request.get_json())

if not Webhook.verify_webhook_signature(signature, request_data, NYLAS_CLIENT_SECRET):
return jsonify({"error": "Invalid signature"}), 403

body = request.json
print("Webhook event received: ", json.dumps(body))

return jsonify({"success": True}), 200

if __name__ == "__main__":
app.run(port=port)