From 176118d4d06acef7cb9cee04b97e95ce79c4e65c Mon Sep 17 00:00:00 2001 From: Peter Boling Date: Mon, 15 Jul 2019 19:17:18 -0700 Subject: [PATCH] Fix references to consumer and access_token Fixes #158 --- README.rdoc | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.rdoc b/README.rdoc index 799595b9..b3fd68fc 100644 --- a/README.rdoc +++ b/README.rdoc @@ -28,28 +28,28 @@ As a matter of fact it has been pulled out from an OAuth Rails GEM (https://ruby We need to specify the oauth_callback url explicitly, otherwise it defaults to "oob" (Out of Band) - @callback_url = "http://127.0.0.1:3000/oauth/callback" + callback_url = "http://127.0.0.1:3000/oauth/callback" -Create a new consumer instance by passing it a configuration hash: +Create a new `OAuth::Consumer` instance by passing it a configuration hash: - @consumer = OAuth::Consumer.new("key","secret", :site => "https://agree2") + oauth_consumer = OAuth::Consumer.new("key", "secret", :site => "https://agree2") Start the process by requesting a token - @request_token = @consumer.get_request_token(:oauth_callback => @callback_url) + request_token = oauth_consumer.get_request_token(:oauth_callback => callback_url) session[:token] = request_token.token session[:token_secret] = request_token.secret - redirect_to @request_token.authorize_url(:oauth_callback => @callback_url) + redirect_to request_token.authorize_url(:oauth_callback => callback_url) When user returns create an access_token hash = { oauth_token: session[:token], oauth_token_secret: session[:token_secret]} - request_token = OAuth::RequestToken.from_hash(@consumer, hash) - @access_token = @request_token.get_access_token + request_token = OAuth::RequestToken.from_hash(oauth_consumer, hash) + access_token = request_token.get_access_token # For 3-legged authorization, flow oauth_verifier is passed as param in callback - # @access_token = @request_token.get_access_token(oauth_verifier: params[:oauth_verifier]) - @photos = @access_token.get('/photos.xml') + # access_token = request_token.get_access_token(oauth_verifier: params[:oauth_verifier]) + @photos = access_token.get('/photos.xml') Now that you have an access token, you can use Typhoeus to interact with the OAuth provider if you choose.