http - 用户授权错误 422 "Unexpected signature"

标签 http quickblox

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

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

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

最佳答案

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

有关签名生成的更多信息请参见 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);
}

关于http - 用户授权错误 422 "Unexpected signature",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22353097/

相关文章:

java - 将字符串路径转换为输入流

php - 如何使用 HTTP PUT 使用 PHP curl 上传文件?

子目录中的 PHP 脚本在调用时自动请求根目录中的相同脚本

php - 使用 CodeIgniter 时出现错误 502 Bad Gateway

c# - 如何使用 SOAP 操作和 HttpClient 向经过授权的网络摄像头发送 ONVIF 请求

ios - QuickBlox 推送通知权限警报时间自定义

android - Quickblox 通知聊天室 IOS 到 Android 中的自定义参数

swift - 在 Quickblox 中,是否可以在不重置的情况下更新用户密码?

javascript - 带有 If-Match header 的 Node.js PATCH 请求

javascript - Quickblox:WEB 聊天中的阻止、解除阻止和阻止列表