Skip to content

Instantly share code, notes, and snippets.

@manuelmeurer
Created September 1, 2010 12:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manuelmeurer/560639 to your computer and use it in GitHub Desktop.
Save manuelmeurer/560639 to your computer and use it in GitHub Desktop.
#!/usr/bin/ruby
if ARGV.length != 2
puts <<-TEXT
Error: wrong number of arguments. Include your app's consumer token and secret:
get_twitter_oauth_credentials.rb CONSUMER_TOKEN CONSUMER_SECRET
Get your consumer token and secret by registering your app at https://twitter.com/apps
TEXT
exit
end
require 'rubygems'
require 'twitter'
consumer_token, consumer_secret = *ARGV
oauth = Twitter::OAuth.new(consumer_token, consumer_secret)
rtoken = oauth.request_token.token
rsecret = oauth.request_token.secret
%x(open http://#{oauth.request_token.authorize_url})
puts 'Please authorize with Twitter and enter the PIN:'
pin = STDIN.gets.chomp
oauth.authorize_from_request(rtoken, rsecret, pin)
puts "Access Token: #{oauth.access_token.token}"
puts "Access Secret: #{oauth.access_token.secret}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment