Skip to content

Instantly share code, notes, and snippets.

@cheald
Created November 1, 2012 22:06
Show Gist options
  • Save cheald/3996974 to your computer and use it in GitHub Desktop.
Save cheald/3996974 to your computer and use it in GitHub Desktop.
require 'oauth'
module Intuit
module API
# This returns a Ruby OAuth consumer object initialized with the correct Intuit endpoints
def self.get_consumer(key, secret)
@consumer = OAuth::Consumer.new(key, secret, {
:site => "https://oauth.intuit.com",
:request_token_path => "/oauth/v1/get_request_token",
:authorize_path => "/oauth/v1/get_access_token",
:access_token_path => "/oauth/v1/get_access_token"
})
end
# This returns the URL the application needs to redirect to for authorization, given a request token
def self.authorize_url(token, returl = "")
return "https://appcenter.intuit.com/Connect/Begin?oauth_token=#{token}"
end
end
end
consumer = Intuit::API.get_consumer("intuit_consumer_key", "intuit_consumer_secret")
token = consumer.get_request_token(:oauth_callback => "http://foo.bar/com/")
puts token.inspect
% ruby token.rb
/usr/local/rvm/gems/ruby-1.9.3-p194-perf@rails3/gems/oauth-0.4.7/lib/oauth/consumer.rb:178:in `request': consumer_key_unknown (OAuth::Problem)
from /usr/local/rvm/gems/ruby-1.9.3-p194-perf@rails3/gems/oauth-0.4.7/lib/oauth/consumer.rb:194:in `token_request'
from /usr/local/rvm/gems/ruby-1.9.3-p194-perf@rails3/gems/oauth-0.4.7/lib/oauth/consumer.rb:136:in `get_request_token'
from token.rb:23:in `<main>'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment