Created
September 1, 2010 12:57
-
-
Save manuelmeurer/560639 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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