【问题标题】:401 Unauthorized -- Invalid grant when requesting refresh token in Doorkeeper401 Unauthorized -- 在 Doorkeeper 中请求刷新令牌时授权无效
【发布时间】:2017-02-02 23:46:05
【问题描述】:

我在请求刷新令牌时遇到问题,它不断返回未经授权的 401 错误。我不知道我是否缺少在我发出请求时传递的参数。

我为刷新令牌添加了门卫配置。

use_refresh_token

这是请求的详细信息:

{{root_url}}/oauth/token

{"refresh_token"=>"034a74c085219fb8297fd8ef9b59f080918f"
 "format"=>:json,
 "controller"=>"/oauth/tokens",
 "action"=>"create",
 "grant_type"=>"refresh_token",
 "client_id"=>"<client_id>",
 "client_secret"=> "<client_secret>"}

错误描述:

{:error=>:invalid_grant,
 :error_description=>
  "The provided authorization grant is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client."}

顺便说一句,我所有的 api 请求身份验证都没有失败,只是这个刷新令牌。我想知道我在请求参数中缺少什么。

【问题讨论】:

    标签: ruby-on-rails ruby api doorkeeper


    【解决方案1】:

    不要传递 client_id 和 client_secret。

    刷新令牌所需的参数是:

    • grant_type
    • 刷新令牌

    可选参数:

    • 范围。

    Refresh Token section of rfc6749: The OAuth 2.0 Authorization Framework

    【讨论】:

    • 是的。我在这里发布后阅读了该文档。但我想知道即使我拥有正确的授权类型和有效的刷新令牌,为什么还要将其视为无效授权类型?为什么不忽略发送请求的额外参数?任何想法。谢谢!
    • 嗯,我想因为这些是授权请求,应该严格对待。
    • 是的,可能是当您传递客户端和机密时,他们认为这是不同的授权类型,而忽略了确切的授权类型和令牌。我觉得你说的有道理。谢谢!
    猜你喜欢
    • 2017-12-25
    • 1970-01-01
    • 1970-01-01
    • 2019-10-17
    • 2013-11-19
    • 2011-11-16
    • 1970-01-01
    • 2016-12-04
    • 2015-02-22
    相关资源
    最近更新 更多