Skip to content

Commit

Permalink
Merge pull request #159 from oauth-xx/pboling/158-fix-readme-references
Browse files Browse the repository at this point in the history
Fix references to consumer and access_token
  • Loading branch information
pboling committed Jul 16, 2019
2 parents cb9b9db + 176118d commit 4cb652e
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions README.rdoc
Expand Up @@ -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.

Expand Down

0 comments on commit 4cb652e

Please sign in to comment.