Skip to content

Instantly share code, notes, and snippets.

@cookie-s
Last active December 16, 2015 09:19
Show Gist options
  • Save cookie-s/5412210 to your computer and use it in GitHub Desktop.
Save cookie-s/5412210 to your computer and use it in GitHub Desktop.
#!env ruby
#encoding: utf-8
#######################################
CONSUMER_KEY = ""
CONSUMER_SECRET = ""
#######################################
require 'oauth'
require 'net/http'
key = CONSUMER_KEY
secret = CONSUMER_SECRET
while key.empty?
print "consumer key: "
key = gets.chomp
end
while secret.empty?
print "consumer secret: "
secret = gets.chomp
end
oauth = OAuth::Consumer.new(
CONSUMER_KEY,
CONSUMER_SECRET,
site: "https://oauth.twitter.com"
)
request_token = oauth.get_request_token
puts "Access this URL: #{request_token.authorize_url}"
print "PIN: "
pin = gets.chomp.to_i
access_token = request_token.get_access_token(
oauth_verifier: pin
)
puts access_token.token, access_token.secret
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment