Closed jabowery closed 8 months ago
Seems like the signature for construct_event doesn't match the example code. The api_key parameter is a KW.
I was able to make the following work,
@webhooks.route("/fax", methods=P)
@csrf.exempt
def view_fax():
telnyx.api_key = current_app.config["TELNYX_API_KEY"]
telnyx.public_key = current_app.config["TELNYX_PUB_KEY"]
try:
event = telnyx.Webhook.construct_event(
request.data.decode("utf-8"),
request.headers.get("Telnyx-Signature-ed25519", None),
request.headers.get("Telnyx-Timestamp", None),
tolerance=3600,
)
except telnyx.error.SignatureVerificationError as e:
print(e.errors)
return "Bad signature", 400
ic(event)
print(f"Received event: {event.data.id}, {event.data.event_type}")
return Response(status=200)
Running https://github.com/team-telnyx/telnyx-python/blob/master/examples/webhooks.py
python --version Python 3.9.6