问题描述
我正在尝试使用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}×tamp=#{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:
这篇关于QuickBlox会话创建:Rails应用程序中的意外签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!