QuickBlox会话创建:Rails应用程序中的意外签名 [英] QuickBlox Session create: Unexpected Signature in Rails App

查看:115
本文介绍了QuickBlox会话创建:Rails应用程序中的意外签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Ruby on Rails从Rest API创建QuickBlox会话.我当前的实现:

I am trying to create QuickBlox session from Rest API using Ruby on Rails. My current implementation:

def qb_signin_params
  timestamp = Time.now.in_time_zone('UTC').to_i
  nonce = rand.to_s[2..6]
  signature_string = "application_id=#{QuickBlox_Application_Id}&auth_key=#{QUICKBLOX_Authorization_KEY}&nonce=#{nonce}&timestamp=#{timestamp}"
  digest = OpenSSL::Digest.new('sha1')
  signature = OpenSSL::HMAC.hexdigest(digest, signature_string, QUICKBLOX_Authorization_SECRET)

  params = Hash.new
  params['application_id'] = QuickBlox_Application_Id
  params['auth_key'] = QUICKBLOX_Authorization_KEY
  params['timestamp'] = timestamp
  params['nonce'] = nonce
  params['signature'] = signature

  params
end

返回以下错误:

unexpected token at '<?xml version="1.0" encoding="UTF-8"?>
<errors> 
  <error>Unexpected signature</error>
</errors>

我已经搜索了多个地方,但是找不到适合Ruby的正确签名.请帮忙.

I have searched through several places, but could never find the correct Signature generation for Ruby. Please help.

推荐答案

查看此 quickblox_api 宝石.这对我来说很棒...

Check out this quickblox_api gem. It worked great for me...

我遇到了同样的问题,然后看那里所做的事情,这几乎就是您(和我)正在做的事情……除了hmac_sha的正文已被整理的事实按照 quickblox文档中的指示/字母,在下面引用:

I was having this same issue, and on looking at what was done in there, which was almost exactly what you ( and I ) were doing... apart from the fact that the body for the hmac_sha was getting sorted alphabetically, as instructed/mentioned on the quickblox documentation which I quote below:

通过增加字符串数组"parameter = value"(以符号&"分隔),将请求主体形成为已排序(按字母顺序,按符号而不是字节排序)

Request body is formed as the sorted (sorting alphabetically, as symbols, not as bytes) by increase the string array 'parameter=value', separated with the symbol "&"

这篇关于QuickBlox会话创建:Rails应用程序中的意外签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆