Skip to content

Instantly share code, notes, and snippets.

@macks
Created May 15, 2010 12:58
Show Gist options
  • Save macks/402180 to your computer and use it in GitHub Desktop.
Save macks/402180 to your computer and use it in GitHub Desktop.
OAuth desktop client example
# OAuth desktop client example
require 'oauth'
CONSUMER_KEY = 'xxxx'
CONSUMER_SECRET = 'xxxx'
access_token = nil
access_secret = nil
consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET, :site => 'http://api.twitter.com')
if access_token && access_secret
access_token = OAuth::AccessToken.new(consumer, access_token, access_secret)
else
request_token = consumer.get_request_token
redirect_to request_token.authorize_url
# Get PIN code
# PIN_CODE = 'xxxxxx'
access_token = request_token.get_access_token(:oauth_verifier => PIN_CODE)
save(access_token.token, access_token.secret)
end
response = access_token.get('/1/statuses/user_timeline.json')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment