使用授权码授予获取三足令牌

Getting a 3-Legged Token with Authorization Code Grant

我目前正在尝试完成这个基于 Getting a 3-Legged Token with Authorization Code Grant

的分步教程

这是我的 cURL 代码:

curl -v "https://developer.api.autodesk.com/authentication/v1/gettoken" 
-X POST 
-H "Content-Type:application/x-www-form-urlencoded" 
-d "client_id=****&
    client_secret=****&
    grant_type=authorization_code&
    code=1O4F-z9gXRtGlBymcGoD3bV3Ws2cqqjeN78PpgGn&
    redirect_uri=http://localhost:3000/api/forge/callback/oauth"

这是我遇到的错误:

{"developerMessage":"The authorization code/refresh token is expired or 
invalid/redirect_uri must have the same value as in the authorization 
request.","userMessage":"","errorCode":"AUTH-004","more 
info":"http://developer.api.autodesk.com/documentation/v1/errors/AUTH-004"}* 
Connection #0 to host developer.api.autodesk.com left intact

注:

我觉得是因为用户登录后得到的code过期时间极短。毕竟,POST /authentication/v1/gettoken 端点应在用户登录后立即调用。

顺便说一句。我经历了同样的步骤,因为我花了一段时间才用收到的 code 创建一个 Postman 请求,所以我最终遇到了和你一样的错误。然后,当我请求另一个code并立即重新发送Postman请求时,它成功了。