Using .NET Framework 4.7 MVC API
When receiving a webhook event from Box to my API, I get all the required information in the header. I am receiving the payload in the body as a Newtonsoft JObject.
I am attempting to use the same code from the SDK (https://github.com/box/box-windows-sdk-v2/blob/main/Box.V2/Managers/BoxWebhooksManager.cs ) to manually verify the signature. However, I am always getting a return of "false" (line 146 from GitHub). Neither of the has values computed ever match what is sent in the header.
Side Note: when converting the payload to a string using the JObject.ToString() method, I get two different hashes calculated based on whether I use JObject.ToString() or the JObject.ToString(Formatting.None) methods. Either way, neither of those two strings give me a matching hash.
// Convert the body of the request into bytes
var bodyBytes = Encoding.UTF8.GetBytes(body.ToString());
var bodyBytes_Format_None = Encoding.UTF8.GetBytes(body.ToString(Formatting.None));
// Add the box time stamp to the they byte array
var allBytes = bodyBytes.Concat(Encoding.UTF8.GetBytes(headers["box-delivery-timestamp"])).ToArray();
var allBytes_Format_None = bodyBytes_Format_None.Concat(Encoding.UTF8.GetBytes(headers["box-delivery-timestamp"])).ToArray();