Join Goodreads

and meet your next favorite book!

Sign Up Now

really simple ruby oauth example

Created by Michael Economy, Oct 08, 2010 442 views
Michael Economy #example authenticates and prints the raw xml for the friend updates.
require 'oauth'
key = BLAH #substitute your keys
secret = BLAH

consumer = OAuth::Consumer.new(key, secret, {:site => "http://www.goodreads.com"})
request_token = consumer.get_request_token
p request_token.authorize_url

#user needs to go to this url and approve it

access_token = request_token.get_access_token
p access_token.get("/updates/friends.xml").body
Chris I was following the example at http://www.goodreads.com/api/oauth_ex... in irb which seems to have come out of this post.

I ran into an error (OAuth::VERSION not defined) and it seems that the require "oauth/consumer" should just be require "oauth".
Michael Economy I've put the require in that example, thanks Chris.