Skip to content

Instantly share code, notes, and snippets.

@mirakui
Created May 3, 2010 13:05
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mirakui/388067 to your computer and use it in GitHub Desktop.
Save mirakui/388067 to your computer and use it in GitHub Desktop.
To get twitter/oauth access token
require 'twitter_oauth'
print 'Consumer Key> '
consumer_key = gets.chomp
print 'Consumer Secret> '
consumer_secret = gets.chomp
t = TwitterOAuth::Client.new(
:consumer_key => consumer_key,
:consumer_secret => consumer_secret
)
req = t.request_token
puts 'OK'
puts "please access and get PIN: #{req.authorize_url}"
print 'PIN> '
pin = gets.to_i
acc = t.authorize(
req.token,
req.secret,
:oauth_verifier => pin
)
puts "Authorized: #{t.authorized?}"
puts "Access Token: #{acc.token}"
puts "Access Secret: #{acc.secret}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment