MiniDr
MiniDr

Reputation: 301

Viber Callback Signature with HMAC

I have been following the documentation in the Viber REST API to create a signature with HMAC using SHA256 Callack Section. The key is authentication token and the value is a json. I tried to create the signature using hash_hmac in PHP language but to no avail. I keep getting different results. I tried to beautify and adjust the structure of json but to no avail.

What I've Done:

public function index(Request $request)
{
    $value = $request->getContent();
    $value = hash_hmac("sha256", $value, '4453b6ac12345678-e02c5f12174805f9-daec9cbb5448c51f');

    return $value;
}

Returned Result: 99b1988ed94ea0e336f5d670c5c71c793bd72f0bb65af2ccbe1f943cae23488c

Key:

4453b6ac12345678-e02c5f12174805f9-daec9cbb5448c51f

Json:

{  
   "event":"delivered",
   "timestamp":1457764197627,
   "message_token":491266184665523145,
   "user_id":"01234567890A="
}

Correct Result Should Be:

9d3941b33d45c165400d84dba9328ee0b687a5a18b347617091be0a56d

Upvotes: 0

Views: 224

Answers (1)

Jerome Lopez
Jerome Lopez

Reputation: 1

you need to convert the content into string first.

enter image description here

Upvotes: 0

Related Questions