Passing parameters thru Ruby's OAuth
I'm using Mirven's Twitter OAuth Sinatra example and trying to figure out how I can send a 'next page' parameter with the Oauth request:
ie. The user attempts to visit /edit/profile
which requires a login so I redirect to /request
which deals with login via twitter - I now want to be able to redirect the user to the address they were originally looking for if they log in successfully.
I thought I could do this in the .get_request_token
line with this code:
@request_token = @consumer.get_request_token({:oauth_callback => "http://#{request.host}/auth"},{:next =&g开发者_JAVA百科t; params['next'] || '/'})
But params
has no additional items in the /auth
handler.
I'm new to OAuth, how would I go about doing this?
Its simpler than I thought, just add your parameters to the oauth_callback url like so:
@request_token = @consumer.get_request_token({:oauth_callback => "http://#{request.host}/auth"},{:next => params['next'] || '/'})
Then put logic in your /auth
handler to redirect according to params['next']
精彩评论