【问题标题】:OAuth signature verification failsOAuth 签名验证失败
【发布时间】:2011-07-09 04:27:12
【问题描述】:

我在设置具有两条腿身份验证的 oauth 提供程序时遇到了一些问题。

我正在使用 oauth-plugin gem 和 oauth gem,除了我的“更新”请求外,一切正常。签名验证过程不断失败。

这是我正在做的事情:

在客户端,我正在使用

oauth = OAuth::AccessToken.new(OAuth::Consumer.new(app_key, app_secret, :site => @api_endpoint))
oauth.get("http://localhost/api/v1/users/1")
oauth.post("http://localhost/api/v1/users", {:email => "testemail@mysite.com"})
oauth.put("http://localhost/api/v1/users", {:tags => ["some", "new", "tags"]})
oauth.delete("http://localhost/api/v1/users/1")

get、post、delete都通过验证正常,但更新失败。

在服务器端,我设置了 ClientApplication 类

  def self.verify_request(request, options = {}, &block)
    begin
      signature = OAuth::Signature.build(request, options, &block)
      return false unless OauthNonce.remember(signature.request.nonce, signature.request.timestamp)
      value = signature.verify
      value
    rescue OAuth::Signature::UnknownSignatureMethod => e
      false
    end
  end

signature.verify 在我的更新请求上失败并传递了其他 3 个请求。有人知道发生了什么吗?

【问题讨论】:

    标签: ruby-on-rails ruby oauth oauth-ruby


    【解决方案1】:

    原来问题在于将参​​数传递给身体。
    我将参数移动到带有 Addressable/uri 的 url 中,这解决了问题。 它的长度会有点限制,但现在还可以。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-06-14
      • 2017-01-03
      • 2012-08-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-11-28
      相关资源
      最近更新 更多