【问题标题】:“Get a 3-Legged Token with Authorization Code Grant” is not OAuth 2.0 RFC complaint and generates an Error 400“通过授权码授予获取 3 条腿令牌”不是 OAuth 2.0 RFC 投诉并生成错误 400
【发布时间】:2020-03-02 03:37:51
【问题描述】:

我已经使用授权码大类型实现了能够通过授权过程获取 OAuth 访问令牌的应用程序。我已经成功地将它与 Google API 服务一起使用,但是当我将它与 AutoDesk Forge API 服务一起使用时遇到了问题。我怀疑 OAuth AutoDesk 不能很好地与 OAuth 2.0 规范确认。

我的应用程序发出这个形状的 HTTP POST 请求:

POST /authentication/v1/gettoken HTTP/1.1
Host: developer.api.autodesk.com
Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
Content-Type: application/x-www-form-urlencoded

grant_type=authorization_code&code=SplxlOBeZQQYbYS6WxSbIA
&redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb

这里我发送 client_id 和 client_secret 作为基本 HTTP 授权的用户名和密码。但我得到一个错误:

{"developerMessage":"The required parameter(s) client_id,client_secret not present in the request","userMessage":"","errorCode":"AUTH-008","more info":"http://developer.api.autodesk.com/documentation/v1/errors/AUTH-008"}

但是,OAuth 规范在第 2.3.1 章 (https://www.rfc-editor.org/rfc/rfc6749#section-2.3.1) 中说:

The authorization server MUST support the HTTP Basic
authentication scheme for authenticating clients that were issued a
client password.

您可以在第 4.2.3 章 (https://www.rfc-editor.org/rfc/rfc6749#section-4.1.3) 中查看服务器必须支持的此类请求示例:

 POST /token HTTP/1.1
 Host: server.example.com
 Authorization: Basic czZCaGRSa3F0MzpnWDFmQmF0M2JW
 Content-Type: application/x-www-form-urlencoded

 grant_type=authorization_code&code=SplxlOBeZQQYbYS6WxSbIA
 &redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb

根据文档,AutoDesk 的要求有所不同:

  curl -v 'https://developer.api.autodesk.com/authentication/v1/gettoken'
  -X 'POST'
  -H 'Content-Type: application/x-www-form-urlencoded'
  -d '
    client_id=obQDn8P0GanGFQha4ngKKVWcxwyvFAGE&
    client_secret=eUruM8HRyc7BAQ1e&
    grant_type=authorization_code&
    code=wroM1vFA4E-Aj241-quh_LVjm7UldawnNgYEHQ8I&
    redirect_uri=http://sampleapp.com/oauth/callback
  '

(在这里,如您所见,AutoDesk 期望 client_id 和 client_secret 在 POST 请求正文中。)这是服务器可能支持的另一种方式,如第 2.3.1 章(https://www.rfc-editor.org/rfc/rfc6749#section-2.3.1)中所述:

Alternatively, the authorization server MAY support including the
client credentials in the request-body

那么,AutoDesk Forge API 服务只支持可选方式,显然不支持强制方式,我说得对吗?

【问题讨论】:

    标签: oauth-2.0 autodesk-forge


    【解决方案1】:

    那么,AutoDesk Forge API 服务只支持可选方式,显然不支持强制方式,我说得对吗?

    肯定 - 可以找到唯一受支持的身份验证格式 here

    【讨论】:

    • 谢谢,布莱恩!这当然是不幸的。很难为标准编写代码。将需要一些用户界面选项或两个请求而不是一个,如果一种方式失败,则尝试另一种方式。并且标准不建议将两者合并到一个请求中(在正文和标头中都进行身份验证)。在身体上做这件事是常见的做法,还是有一些理由这样做,这可能有助于我更好地理解它并使我的决定更明智?
    • 如果没有与我们的架构师进行仔细检查,我有根据的猜测是,将客户端密码以基本身份验证的形式放在标头中可能被认为不太安全(考虑到非常身份验证类型是不安全...)-虽然从技术上讲,它与将其放入体内并没有完全不同...
    猜你喜欢
    • 2018-12-31
    • 2019-03-21
    • 2021-03-06
    • 2020-09-08
    • 2020-12-11
    • 1970-01-01
    • 2017-01-10
    • 1970-01-01
    • 2012-05-31
    相关资源
    最近更新 更多