Edited at

Twitter の AccessToken と AccessTokenSecret を Ruby で取得する

More than 5 years have passed since last update.

require "oauth"

consumer_key = "YOUR_KEY"
consumer_secret = "YOUR_SECRET"
consumer = OAuth::Consumer.new consumer_key, consumer_secret, site: "https://api.twitter.com"

request_token = consumer.get_request_token

puts "Please visit here: #{request_token.authorize_url}"
STDERR.print "Then put your PIN: "

access_token = request_token.get_access_token oauth_verifier: gets.chomp
puts "Token: #{access_token.token}"
puts "Secret: #{access_token.secret}"