Skip to content

Instantly share code, notes, and snippets.

@mojodna
Created November 1, 2008 02:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mojodna/21466 to your computer and use it in GitHub Desktop.
Save mojodna/21466 to your computer and use it in GitHub Desktop.
OAuth::RequestProxy for Hashes to facilitate simpler signature creation.
module OAuth
module RequestProxy
# RequestProxy for Hashes to facilitate simpler signature creation.
# Usage:
# request = OAuth::RequestProxy.proxy \
# "method" => "iq",
# "uri" => [from, to] * "&",
# "parameters" => {
# "oauth_consumer_key" => oauth_consumer_key,
# "oauth_token" => oauth_token,
# "oauth_signature_method" => "HMAC-SHA1"
# }
#
# # can't pass options unless they respond to :secret, so use this alternative
# signature = OAuth::Signature.sign(request) do |token|
# [oauth_token_secret, oauth_consumer_secret]
# end
class MockRequest < OAuth::RequestProxy::Base
proxies Hash
def parameters
@request["parameters"]
end
def method
@request["method"]
end
def uri
@request["uri"]
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment