1

So I'm using a Venmo authentication in my Rails site. Basically the user clicks the authenticate button, and is sent to Venmo to authorize my app. Then when authorized, Venmo redirects back to my app but with the url in the format: localhost:3000/dashboard?access_token=accesstokenhere

I need to parse this URL for the 'accesstokenhere' part to then make calls to the Venmo API. What's the easiest way to parse a URL here for the access token?

For more explanation of how this works, here's the Venmo API quickstart guide

blunatic
  • 325
  • 2
  • 6
  • 16
  • I suggest to use Omniauth and its Venmo strategy instead of rolling out your own authentication solution. https://github.com/tmilewski/omniauth-venmo – Gergo Erdosi May 08 '14 at 21:58
  • I attempted using Omniauth but my User authentication is based on Devise and I want an "Authenticate Venmo" button within the user's profile/dashboard instead of a "Login with Venmo" where the user is logged in as a Venmo account user. – blunatic May 08 '14 at 22:15

2 Answers2

3

You should have access to the token as params[:access_token] in the Rails controller that handles the callback.

Documentation: http://guides.rubyonrails.org/action_controller_overview.html#parameters

crsven
  • 186
  • 2
  • thanks, exactly what I needed. (chosen as best answer over Buck's only because of the documentation link) – blunatic May 08 '14 at 22:13
0

Rails controllers have access to URL parameters via the params hash. You can get the token with params[:access_token].

Buck Doyle
  • 6,333
  • 1
  • 22
  • 35