Skip to content

Instantly share code, notes, and snippets.

@stympy
Created March 12, 2010 22:51
Show Gist options
  • Save stympy/330890 to your computer and use it in GitHub Desktop.
Save stympy/330890 to your computer and use it in GitHub Desktop.
ca = ClientApplication.create(:name => 'Test Consumer App', :url => 'http://consumerapp.local')
consumer = OAuth::Consumer.new(ca.key, ca.secret, :site => 'http://localhost:3000')
request_token = consumer.get_request_token
`open #{request_token.authorize_url}`
# after POSTing that form...
db_request_token = RequestToken.last
# the POST would redirect to #{ca.callback_url}?oauth_token=#{db_request_token.token}&oauth_verifier=#{db_request_token.verifier} if ca.callback_url is not nil
access_token = OAuth::RequestToken.new(consumer, request_token.token, db_request_token.token).get_access_token(:oauth_verifier => db_request_token.verifier)
access_token.get('/some/protected/action')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment