QuickBlox 会话创建:Rails 应用程序中的意外签名
QuickBlox Session create: Unexpected Signature in Rails App
我正在尝试在 Rails 上使用 Ruby 从 Rest API 创建 QuickBlox 会话。我当前的实现:
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
Returns 以下错误:
unexpected token at '<?xml version="1.0" encoding="UTF-8"?>
<errors>
<error>Unexpected signature</error>
</errors>
我搜索了好几个地方,但一直找不到 Ruby 的正确签名生成。请帮忙。
看看这个 quickblox_api gem。它对我很有用...
我遇到了同样的问题,看看里面做了什么,这几乎正是你(和我)正在做的......除了 hmac_sha
按字母顺序排序,如 quickblox documentation 上的 instructed/mentioned,我在下面引用:
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 "&"
我正在尝试在 Rails 上使用 Ruby 从 Rest API 创建 QuickBlox 会话。我当前的实现:
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
Returns 以下错误:
unexpected token at '<?xml version="1.0" encoding="UTF-8"?>
<errors>
<error>Unexpected signature</error>
</errors>
我搜索了好几个地方,但一直找不到 Ruby 的正确签名生成。请帮忙。
看看这个 quickblox_api gem。它对我很有用...
我遇到了同样的问题,看看里面做了什么,这几乎正是你(和我)正在做的......除了 hmac_sha
按字母顺序排序,如 quickblox documentation 上的 instructed/mentioned,我在下面引用:
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 "&"