通过 Ruby 的 OAuth 传递参数

发布于 2024-08-28 16:17:52 字数 737 浏览 3 评论 0 原文

我正在使用 Mirven 的 Twitter OAuth Sinatra 示例,并试图弄清楚如何才能使用 Oauth 请求发送“下一页”参数:

即。用户尝试访问需要登录的 /edit/profile ,因此我重定向到 /request ,它处理通过 Twitter 的登录 - 我现在希望能够重定向用户如果登录成功,则转到他们最初查找的地址。

我想我可以在 .get_request_token line 包含以下代码:

  @request_token = @consumer.get_request_token({:oauth_callback => "http://#{request.host}/auth"},{:next => params['next'] || '/'})

但是 params/auth 处理程序中没有其他项目。

我是 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 => params['next'] || '/'})

But params has no additional items in the /auth handler.

I'm new to OAuth, how would I go about doing this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦境 2024-09-04 16:17:52

它比我想象的更简单,只需将参数添加到 oauth_callback url,如下所示:

  @request_token = @consumer.get_request_token({:oauth_callback => "http://#{request.host}/auth"},{:next => params['next'] || '/'})

然后将逻辑放入您的 /auth 处理程序中,以根据 params['next'] 进行重定向

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']

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文