Skip to content

Instantly share code, notes, and snippets.

@luigi
Created September 1, 2010 03:03
Show Gist options
  • Save luigi/560159 to your computer and use it in GitHub Desktop.
Save luigi/560159 to your computer and use it in GitHub Desktop.
# Create a new Twitter app on Twitter.com - I called mine "Utwilities" and plan to use it for everything
# Get the Consumer Key and Consumer Secret from the app page
oauth = Twitter::OAuth.new('consumer key', 'consumer secret')
request = oauth.request_token
request_token = request.token
# Go to: http://twitter.com/oauth/authorize?oauth_token=#{request_token}&oauth_callback=oob
# That will give you the PIN
access = oauth.authorize_from_request(request.token, request.secret, 'THE_PIN')
# Save these to your database or keep in a config file
access_token = oauth.access_token.token
access_secret = oauth.access_token.secret
# Now you can use the client
client = Twitter::Base.new(oauth)
# If you need to instantiate a client later, do this:
oauth = Twitter::OAuth.new('consumer key', 'consumer secret')
oauth.authorize_from_access('access token', 'access secret')
client = Twitter::Base.new(oauth)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment