Recent searches
No recent searches
Webhook API Verification in Azure Function
Posted Mar 08, 2024
I am trying to add security to our webhook call but I can't figure out what I need for the body of the request. The example talks about a middleware to get rawBody but I don't have access to that. I tried using .json() but it isn't creating a valid signature.
Here are the options for getting the body of a request...arrayBuffer()
returns Promise<ArrayBuffer>
blob()
returns Promise<Blob>
formData()
returns Promise<FormData>
json()
returns Promise<unknown>
text()
returns Promise<string>
const headers = Object.fromEntries(request.headers.entries());
const signature = headers['x-zendesk-webhook-signature'];
const timestamp = headers['x-zendesk-webhook-signature-timestamp'];
const requestData: any =await request.json();
const validSign =isValidSignature(signature.toString(), timestamp, requestData);
Result
{
"sig": "ye2uzjct14Laj8doyeeyPCCgpWeOjIwzVxRY9unbhDo=",
"time": "2024-03-08T12:34:55Z",
"bod": {
"id": "81823",
"tags": "order cs_afterhours customer-success"
},
"verify": false
}
0
1 comment
Tipene Hughes
Would you mind sharing a link to the example you're referencing so I can be sure that I'm giving you the correct information.
Thanks,
Tipene
0