Skip to content

Commit a41621e

Browse files
committed
Add a code comment for webhook verification to chem-sync-local-flask
1 parent c05db92 commit a41621e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • examples/chem-sync-local-flask/local_app

examples/chem-sync-local-flask/local_app/app.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@ def health_check() -> tuple[str, int]:
2121
def receive_webhooks(target: str) -> tuple[str, int]: # noqa: ARG001
2222
# For security, don't do anything else without first verifying the webhook
2323
app_id = request.json["app"]["id"] # type: ignore[index]
24+
25+
# Important! To verify webhooks, we need to pass the body as an unmodified string
26+
# Flask's request.data is bytes, so decode to string. Passing bytes or JSON won't work
2427
verify_app_installation(app_id, request.data.decode("utf-8"), request.headers)
28+
2529
logger.debug("Received webhook message: %s", request.json)
2630
# Dispatch work and ACK webhook as quickly as possible
2731
_enqueue_work()

0 commit comments

Comments
 (0)