I'm trying to validate the Shopify HMAC during an OAUTH request and the hash I generate does not match the one provided as part of the request.
I've found some other threads but they are either outdated, as the documentation now states it uses a GET request instead of POST, or unanswered in java.
My C# code is as follows:
string key = "mysecretkey";
string message = string.Format("shop={0}×tamp={1}", shop, timestamp);
System.Text.ASCIIEncoding encoding = new ASCIIEncoding();
byte[] keyBytes = encoding.GetBytes(key);
byte[] messageBytes = encoding.GetBytes(message);
System.Security.Cryptography.HMACSHA256 cryptographer = new System.Security.Cryptography.HMACSHA256(keyBytes);
byte[] bytes = cryptographer.ComputeHash(messageBytes);
string digest = BitConverter.ToString(bytes).Replace("-", "");
bool valid = digest == hmac.ToUpper();
I'm guessing the message is being built incorrectly but I've followed the official documentation with no luck.
Can someone help please?
code
&shop=shop
&state=state
×tamp=timestamp
; It worked for me – Parag Jadhav