【问题标题】:Omniauth: can't change response_type to "token" in StrategyOmniauth:无法在策略中将 response_type 更改为“token”
【发布时间】:2011-08-30 21:37:19
【问题描述】:

我正在实施一种策略,以连接到使用 oauth-plugin 实施的 OAuth 提供程序。在“request_phase”函数中,我写道:

def request_phase
    options[:response_type] = 'token
    super
end

但是在发送的HTTP请求中,却有“...&response_type=code” 我按照其他示例在 request_phase 中设置 response_type,例如使用 SalesForce 策略进行演示: https://github.com/quintonwall/omniauth-rails3-forcedotcom/wiki/Build-Mobile-Apps-in-the-Cloud-with-Omniauth,-Httparty-and-Force.com

请告知如何更改 response_type。

谢谢 拉米

【问题讨论】:

    标签: ruby-on-rails ruby omniauth oauth-2.0


    【解决方案1】:

    OAuth 2.0 documentation 所指定,"code" 是授权代码流的唯一有效值:

    response_type
             REQUIRED.  Value MUST be set to "code".
    

    然后,您必须使用auth_code 再次请求令牌。您使用的提供程序可能仅支持此方法。

    使用token 作为响应类型的流是implicit grant 流,它有相当不同的用例,您尝试使用的提供者可能不支持。

    【讨论】:

      猜你喜欢
      • 2019-08-06
      • 2014-12-31
      • 1970-01-01
      • 1970-01-01
      • 2017-09-18
      • 2015-06-02
      • 1970-01-01
      • 1970-01-01
      • 2022-12-15
      相关资源
      最近更新 更多