Skip to content

Instantly share code, notes, and snippets.

@alperkokmen
Created December 4, 2012 06:39
Show Gist options
  • Save alperkokmen/4201305 to your computer and use it in GitHub Desktop.
Save alperkokmen/4201305 to your computer and use it in GitHub Desktop.
Twitter OAuth Helper
# handy ruby script which allows developers to get oauth token/secret
# for a twitter application identified by consumer_key and consumer_secret.
require 'oauth'
print "consumer_key: "
consumer_key = STDIN.gets.strip
print "consumer_secret: "
consumer_secret = STDIN.gets.strip
consumer = OAuth::Consumer.new(
consumer_key,
consumer_secret,
{
site: 'http://twitter.com',
request_token_path: '/oauth/request_token',
access_token_path: '/oauth/access_token',
authorize_path: '/oauth/authorize'
})
request_token = consumer.get_request_token
puts "go to this url in your browser: #{request_token.authorize_url}"
print "pin: "
pin = STDIN.gets.strip
access_token = request_token.get_access_token(oauth_verifier: pin)
token = access_token.token
secret = access_token.secret
puts "token: #{token}"
puts "secret: #{secret}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment