用户授权错误422"意外签名"

时间:2014-03-12 13:30:33

标签: http quickblox

我尝试将用户授权从我的c#app运行到https://api.quickblox.com/auth.json。我得到了响应错误代码** 422意外签名。有谁知道这意味着什么或如何调试错误?

我发送了以下字符串作为参数:

{  "application_id": "MYAPPID",  
   "auth_key": "MYAUTHKEY",  
   "timestamp": "1394632995",  
   "nonce": "487",  
   "signature": "6bf130657ee04e68ff41a08ace44480f90b49f11",  
   "user": {    
      "login": "mylogin",    
      "password": "mypassword"  
   }
}

1 个答案:

答案 0 :(得分:0)

这意味着您的签名值错误;

有关签名生成的更多信息,请访问http://quickblox.com/developers/Authentication_and_Authorization#Signature_generation

您可以在此处找到C#的一些示例 https://github.com/QuickBlox/SimpleSample-BackgroundMode-WindowsPhone7/blob/master/QuickBloxSDK-Silverlight/QuickBlox.cs

StringBuilder signature = new StringBuilder();
signature.Append("application_id");
signature.Append("=");
signature.Append(this.ApplicationId.ToString());
signature.Append("&");
signature.Append("auth_key");
signature.Append("=");
signature.Append(this.AuthenticationKey);
signature.Append("&");
signature.Append("nonce");
signature.Append("=");
signature.Append(randomResult);
signature.Append("&");
signature.Append("timestamp");
signature.Append("=");
signature.Append(ts.ToString());


byte[] key = Encoding.UTF8.GetBytes(this.AuthenticationSecret);
this.Encode(signature.ToString(),key)

private  string Encode(string input, byte[] key)
{
    HMACSHA1 myhmacsha1 = new HMACSHA1(key);
    byte[] byteArray = Encoding.UTF8.GetBytes(input);
    MemoryStream stream = new MemoryStream(byteArray);
    return myhmacsha1.ComputeHash(stream).Aggregate("", (s, e) => s + String.Format("{0:x2}", e), s => s);
}
相关问题