是否可以向oauth传递参数?

问题描述 投票:0回答:1

我正在将 Devise 与 gems“omniauth-google-oauth2”、“omniauth-linkedin-oauth2”和“omniauth-oauth2”一起使用,并寻找一种方法来做这样的事情:

<%= link_to user_google_oauth2_omniauth_authorize_path(registerable: true) %>

...这样我就可以根据响应进行条件(具体来说,允许用户从一个页面以这种方式注册,但不能从另一个页面注册)

理想的情况是查询在身份验证参数中传回给我,但任何可以影响返回给我的参数的方式都可以。但我在自述文件中没有看到任何表明这是可能的宝石。

作为一种可能的解决方法,我认为我们可以在他们访问相关页面之一时设置 cookie 或存储会话值,然后在收到 oauth 请求时检查(并删除)该值,但这看起来非常 hacky。

ruby-on-rails-4 oauth-2.0 devise omniauth
1个回答
0
投票

OAuth 支持状态参数。您可以这样添加:

<%= link_to user_google_oauth2_omniauth_authorize_path(state: "some_message") %>
© www.soinside.com 2019 - 2024. All rights reserved.