OAuth signature verification fails

穿精又带淫゛_ 提交于 2019-12-08 13:39:04

问题


I'm having some problem setting up an oauth provider with two-legged authentication.

I'm using the oauth-plugin gem and the oauth gem, everything works fine except for my "update" requests. The signature verification process keeps failing.

Here is what I'm doing:

In the client, I'm using

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 and delete all go through authentication fine, but update fails.

On the server side, I have my ClientApplication class set up

  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 fails on my update requests and passes on the other 3 requests. Anybody know what's happening?


回答1:


Turns out the problem is with passing the params through the body.
I moved the params into the url with Addressable/uri, and that fixed the problem. It's gonna be a little limiting in terms of length, but ok for now.



来源:https://stackoverflow.com/questions/5200240/oauth-signature-verification-fails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!