Skip to content

Instantly share code, notes, and snippets.

@mataki
Created August 19, 2010 10:36
Show Gist options
  • Save mataki/537574 to your computer and use it in GitHub Desktop.
Save mataki/537574 to your computer and use it in GitHub Desktop.
require "rubygems"
require "oauth"
require "json"
require "action_pack"
require "active_support"
consumer_key = "AsuesLsQlNSqTmlr3off"
consumer_secret = "n7xvBRGBfdtIm2jQ5T2U65T7XO2hmX3FJt5f7cJw"
consumer = OAuth::Consumer.new(consumer_key,
consumer_secret,
:site => "http://youroom.local:3000")
access_token = OAuth::AccessToken.new(consumer, "3BlE7YBvgqnv2xLmjxct", "o7WlPDjcQHsZoiOfTwPckxuFJYkrEO39CbyGx0T5")
raw_req = consumer.send :create_http_request, :put, "http://enterprise.youroom.local:3000/billings/3/billing_users.json", { :aaaaaaaaaa => :b }
consumer.signature_base_string(raw_req, access_token) # => "PUT&http%3A%2F%2Fyouroom.local%3A3000%2Fbillings%2F3%2Fbilling_users.json&oauth_consumer_key%3DAsuesLsQlNSqTmlr3off%26oauth_nonce%3D7Mra8Vgk20UBTETEQtzuK5nwWrR8aC8FdCDrJwJ6las%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1282214010%26oauth_token%3D3BlE7YBvgqnv2xLmjxct%26oauth_version%3D1.0"
raw_req = consumer.send :create_http_request, :post, "http://enterprise.youroom.local:3000/billings/3/billing_users.json", { :aaaaaaaaaa => :b }.to_query
consumer.signature_base_string(raw_req, access_token) # => "POST&http%3A%2F%2Fyouroom.local%3A3000%2Fbillings%2F3%2Fbilling_users.json&oauth_body_hash%3DeE7fDv2j%252FAh943qhUmXUXR1rS0Y%253D%26oauth_consumer_key%3DAsuesLsQlNSqTmlr3off%26oauth_nonce%3DD3RqBprosdQIsC4xij5yw1UEy0mVVyklicGoHIyuawA%26oauth_signature_method%3DHMAC-SHA1%26oauth_timestamp%3D1282214010%26oauth_token%3D3BlE7YBvgqnv2xLmjxct%26oauth_version%3D1.0"
req = consumer.create_signed_request(:post, "http://enterprise.youroom.local:3000/billings/3/billing_users.json", access_token, { :a => :b }) # => #<Net::HTTP::Post POST>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment