Web Hook Verification
When integrating Inqud web hooks into your application, it's crucial to verify the authenticity of incoming web hook requests. This ensures that the requests are genuinely from Inqud and not from a malicious source. Inqud includes an HMAC-SHA1 signature in the X-Payload-Digest
header of each web hook request, which you can use to verify the request.
Below is a sample Python function that demonstrates how to verify the signature of a webhook request:
Secret Value: The
SECRET
variable should be set to the secret value you supplied during create of a webhook.Verify Signature Function: The
verifySignature
function takes the raw response body (callback_raw_response
) and the headers (callback_headers
) of the web hook request.it extracts the signature from the
X-Payload-Digest
header.It then generates a new
HMAC-SHA1
signature using the secret value and the raw response body.Finally, it compares the generated signature with the signature from the header and returns
True
if they match, indicating that the webhook is authentic.
Sample Data: The
callback_raw_response
andcallback_headers
variables contain sample data for testing the function.
Last updated