Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn oauth_token & oauth_verifier into Access Token with OAuth gem

I am trying to use to OAuth gem to authenticate Evernote in my Ruby on Rails app. I'm using a tutorial for authenticating Twitter - http://blog.brijeshshah.com/integrate-twitter-oauth-in-your-rails-application/ because I couldn't find an Evernote one.

So far I have gotten the user to authorize my application and now have the temporary credentials:

customer = OAuth::Consumer.new("xxx", "xxx",{
  :site=>"https://sandbox.evernote.com/",
  :request_token_path => "/oauth",
  :access_token_path => "/oauth",
  :authorize_path => "/OAuth.action"})
@request_token = customer.get_request_token(:oauth_callback => "http://localhost:3000/create_evernote_step_2")

session[:request_token] = @request_token.token
session[:request_token_secret] = @request_token.secret       

redirect_to @request_token.authorize_url

So now I have the oauth_token and oauth_verifier, and need to turn these into the access token. This part of the Twitter tutorial seems specific to Twitter, so I'm now sure how to process in the case of Evernote. Can anyone help me out?

like image 484
ben Avatar asked Feb 15 '11 02:02

ben


1 Answers

Evernote's sample code now contains a Ruby OAuth example that uses the OAuth gem. You can download the sample code from http://www.evernote.com/about/developer/api/. In this case, the next step is to exchange the temporary credentials for token credentials:

access_token = @request_token.get_access_token(:oauth_verifier => oauth_verifier)

The oauth_verifier is passed to your application as part of the callback URL.

like image 187
Seth Avatar answered Sep 28 '22 04:09

Seth