Omniauth - 在重定向网址中设置自定义参数
我正在使用最新(1.0.1)版本的 Omniauth 和 Rails 3.1.3。 现在,我正在使用 37signals 策略的omniauth。我想根据 auth url 传递自定义参数(“state”参数)(例如 http://localhost: 3000/auth/37signals/5 应重定向到 https://launchpad.37signals.com/authorization/new?(...)&state=5
我尝试设置(暂时)固定状态,类似于
provider "37signals", "my_client_id", "my_secret", {state: "5"}
但是,在我的网址中(仍然)没有状态参数。 有什么想法吗?可以设置该参数吗?
I'm using latest (1.0.1) version of Omniauth with rails 3.1.3.
Right now, I'm using omniauth with 37signals strategy. I would like to pass custom argument ("state" parameter) depending on auth url (eg. http://localhost:3000/auth/37signals/5 should redirect to https://launchpad.37signals.com/authorization/new?(...)&state=5
I've tried to set (temporarily) fixed state, with something like
provider "37signals", "my_client_id", "my_secret", {state: "5"}
However, in my url there is (still) no state param.
Any ideas why? Is it possible to set that param?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
创建 url 时,您只需在查询字符串中添加状态,它也将在回调 url 中可用。
现在回调 url 将是
现在在回调处理程序中您可以处理状态
when creating the url you can just add state in the Query String and it will be available in the callback url as well.
now the callback url will be
Now in the callback handler you can process the state
您必须使用
:params
选项,因为在回调中以及稍后您可以访问
request.env['omniauth.params']
来获取哈希值! :)(复制自此答案)
You have to use the
:params
options, as inand later in the callback you can access
request.env['omniauth.params']
to get the hash! :)(copied from this answer)
我认为你不能为网址附加其他参数。服务器端就像指定参数一样。
也许你需要看看这个。
https://raw.github.com/tallgreentree/omniauth-37signals/e94a70a08c4535abb91338d8ef73593e143f1e5a/lib/omniauth/strategies/37signals.rb
I think you can not to appending other params for the url. the server side just like the specify params.
maybe you need to take a look this one.
https://raw.github.com/tallgreentree/omniauth-37signals/e94a70a08c4535abb91338d8ef73593e143f1e5a/lib/omniauth/strategies/37signals.rb