“获得具有授权码授予的三足令牌”产生错误400

时间:2018-07-24 01:49:20

标签: oauth-2.0 autodesk-forge

我正在尝试创建一个网页,该网页实现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

     

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

     

连接应用程序

     

请稍后再试。

我上面的代码非常简单:您能帮我确定错误的根源并告诉我如何解决它吗?

1 个答案:

答案 0 :(得分:1)

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

此外,

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

enter image description here

相关问题