【问题标题】:"Get a 3-Legged Token with Authorization Code Grant" generates an Error 400“使用授权码授予获取 3 条腿令牌”生成错误 400
【发布时间】:2018-12-31 12:39:20
【问题描述】:

我正在尝试创建一个网页,以实现 Autodesk 的 Forge 教程中描述的“Get a 3-Legged Token with Authorization Code Grant”过程的第 1 步。但是当我运行它时,我得到一个错误:错误:400 - 无效的redirect_uri

这是我的代码:

    <!DOCTYPE html> 
    <html lang="en"> 
    <head>
    <title>Get_a_3-Legged_Token_with_Authorization_Code_Grant.php</title>
    </head> 
    <body> 
    <?php 
    // Derivedfrom API tutorial here: 
    // https://developer.autodesk.com/en/docs/oauth/v2/tutorials/get-3-legged-token/

    $client_id                          = "HAqDtKO7VbuRgH0nL0MFJ0B02ElBEK3l";
    $forge_Callback_URL_w_query_string  = "http%3A%2F%2prod.sonautics.com/send_scan.php%3Fcmd%3Drefresh";
    $forge_Your_WebSite_URL             = "httpp%3A%2F%2prod.sonautics.com";

    echo    '<a href="https://developer.api.autodesk.com/authentication/v1/authorize?response_type=code'
        .   '&client_id=' . $client_id      
        .   '&redirect_uri=' . forge_Callback_URL_w_query_string    
        .   '&scope=data:read">Click here to grant access to your data!</a>'; ?> 
    </body> 
    </html>

我收到一个页面,上面写着:

哎呀

错误:400 - 无效的 redirect_uri

我们在应用程序配置方面遇到问题。

连接应用程序

请稍后再试。

我上面的代码很简单:你能帮我找出错误的来源并告诉我如何解决吗?

【问题讨论】:

  • 我看到你的例子是使用httpp 而不是http,也许这也受到了影响。

标签: oauth-2.0 autodesk-forge


【解决方案1】:

redirect_uri 参数应与 Callback URL 匹配,就像您在 Forge 应用程序中提到的 client id 的以下快照一样。请检查它们当前是否不匹配。

另外,

通过 Forge Viewer 查看模型的誓约范围建议使用 viewables:read 代替。一旦暴露了具有此范围的令牌,其他人就可以使用范围 data:read 读取您存储桶中的模型文件。请查看此公告:https://forge.autodesk.com/blog/new-viewablesread-scope

【讨论】:

  • 事实证明,即使该示例显示了 URI 的未编码版本,它也不喜欢它。但是我只是将 URI 更改为“https://”并且它起作用了。
  • 我也有类似的问题。我正在关注 3-legged 教程,我匹配了 URI 和 URL,尝试交换数据:read 为 viewables:read,并尝试切换到 https:// 而不是 http://,但我仍然收到错误 @987654332 @你知道有什么问题吗?
  • 我遇到了类似的问题。我想知道授权码的有效期是多久?
  • @Sumana 我相信有效期为7天,可以在authentication docs上找到。
  • @Sumana Autodesk Forge OAuth 授权码的生命周期为 1 分钟。
猜你喜欢
  • 2019-03-21
  • 2020-03-02
  • 2022-08-16
  • 1970-01-01
  • 2019-08-06
  • 1970-01-01
  • 1970-01-01
  • 2019-04-15
  • 1970-01-01
相关资源
最近更新 更多