Cloud Development Kit

Computing HMAC challenge in C#

Hello, I am trying to compute the HMAC from the challenge. I keep getting an InvalidHMACSignatureException error.

Here is my code:

  string hmk = vdata.hmackey;
  string apk = vdata.appkey;
  string userk = appkey + hmackey;
  string comp;
  try
  {
  using (HMACSHA512 signingkey = new HMACSHA512(System.Text.Encoding.UTF8.GetBytes(userk)))
  {
  var compk = signingkey.ComputeHash(System.Text.Encoding.UTF8.GetBytes(vdata.challenge));
  comp = BitConverter.ToString(compk);
  }
  string result = Regex.Replace(comp, @"[^a-zA-Z0-9]", "");
  return result;
  }
  catch (Exception ac)
  {
  return ac.ToString();
  }

Am I missing something when computing this?

1 Comment

Dear Remington,

Currently, you should use the HMAC key you can find in your CDK dashboard (just where you found your API key).

Then, you should add it as explained in the API documentation of the cloud: http://doc.myscript.com/MyScriptCloud/3.2.0/reference/index.html

Let us know if you need further explanation.

Best regards,

Olivier
Login or Signup to post a comment