I am developing a Node.js application and I am struggling to validate the Mandrill Webhook request.
As stated here http://help.mandrill.com/entries/23704122-Authenticating-webhook-requests , this should be something like this in PHP:
function generateSignature($webhook_key, $url, $params) { $signed_data = $url; ksort($params); foreach ($params as $key => $value) { $signed_data .= $key; $signed_data .= $value; } return base64_encode(hash_hmac('sha1', $signed_data, $webhook_key, true)); }
So, I came up with this:
var url = "http://...."; var post = "<POST Data>"; require('crypto').createHmac("SHA1", "<Webhook Signature Key>").update(url+post).digest("base64");
Unfortunately this does not work. I get a different signature.
POST data is received using urlencoded, for example:
mandrill_events=%5B%7B%22event%22%3A%22inbound ...
Urldecoded:
mandrill_events=[{"event":"inbound ...
The Mandrill document states that the delimiter should not be included, so this is the line I'm using (without = ):
mandrill_events[{"event":"inbound ...
Any ideas on this?
PS: I double-checked the URL and Webhook key :-).
source share