Skip to content

Instantly share code, notes, and snippets.

@kvnsmth
Created February 15, 2011 21:11
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 kvnsmth/828251 to your computer and use it in GitHub Desktop.
Save kvnsmth/828251 to your computer and use it in GitHub Desktop.
A quick script to get an OAuth access token
# run from a command line to get the access token information
require 'rubygems'
require 'oauth'
@consumer_key = "YOUR_CONSUMER_KEY"
@consumer_secret = "YOUR_CONSUMER_SECRET"
@consumer = OAuth::Consumer.new(@consumer_key, @consumer_secret, {
:site => "http://api.awesomeapp.com" # example: "http://api.twitter.com"
})
@request_token=@consumer.get_request_token
# visit URL output here and authorize
puts @request_token.authorize_url
# type PIN in here and press enter
pin = gets
@access_token = @request_token.get_access_token(:oauth_token_secret => pin)
# TADA!
puts "token: #{@access_token.token}"
puts "secret: #{@access_token.secret}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment