Created
June 13, 2013 14:28
-
-
Save dannguyen/5774111 to your computer and use it in GitHub Desktop.
Generating Twitter app credentials at the command line
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
require 'rubygems' | |
require 'twitter_oauth' | |
require 'json' | |
client = TwitterOAuth::Client.new( | |
:consumer_key => 'THEKEY', | |
:consumer_secret => 'THESECRET' | |
) | |
request_token = client.authentication_request_token( :oauth_callback => 'oob') | |
puts request_token.authorize_url | |
# This is where the user visits the authorized URL | |
print 'Please visit the URL listed above. And then enter the code shown to you: ' | |
## This is where the user enters the code | |
code = gets.strip | |
access_token = client.authorize( | |
request_token.token, | |
request_token.secret, | |
:oauth_verifier => code | |
) | |
cred_obj = [:screen_name, :oauth_token_secret, :oauth_token].inject({}) do |hsh, att| | |
hsh[att] = access_token.params[att] | |
hsh | |
end | |
puts "\nCredentials:\n" | |
puts JSON.pretty_generate(cred_obj) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment