【问题标题】:Autodesk-forge viewer: Access tokenAutodesk-forge 查看器:访问令牌
【发布时间】:2020-09-17 02:04:36
【问题描述】:

我正在按照 forge 教程将 forge 查看器嵌入到 html 页面中。 我最终进入了这个伪造的页面,链接:https://autodesk-forge.github.io/forge-tutorial-postman/display_svf.html 我了解如何使用 cURL 检索访问令牌,但是我想修改该网站,这样我就不必自己输入访问令牌。 我希望将 cURL 响应中的访问令牌自动导入为该网站的访问令牌。这怎么可能。 网页代码在这里:https://github.com/Autodesk-Forge/forge-tutorial-postman/blob/master/docs/display_svf.html 当我在网页上点击提交时,如何添加一个函数/方法来自动检索访问令牌。 任何帮助都非常受欢迎! 干杯!

【问题讨论】:

    标签: oauth autodesk-forge


    【解决方案1】:

    您要查找的服务器端代码是:

    app.get('/api/forge/oauth', function (req, res) {
        Axios({
            method: 'POST',
            url: 'https://developer.api.autodesk.com/authentication/v1/authenticate',
            headers: {
                'content-type': 'application/x-www-form-urlencoded',
            },
            data: querystring.stringify({
                client_id: FORGE_CLIENT_ID,
                client_secret: FORGE_CLIENT_SECRET,
                grant_type: 'client_credentials',
                scope: scopes
            })
        })
            .then(function (response) {
                // Success
                access_token = response.data.access_token;
                console.log(response);
                res.send('<p>Authentication success!</p>');
            })
            .catch(function (error) {
                // Failed
                console.log(error);
                res.send('Failed to authenticate');
            });
    });

    请参阅Forge 2-Legged Authentication 教程以获取代码和更多详细信息。我们在Learn Autodesk Forge 上还有更多教程和工作流程。

    【讨论】:

      猜你喜欢
      • 2016-12-20
      • 2021-11-12
      • 1970-01-01
      • 2021-09-19
      • 2018-05-21
      • 2020-10-23
      • 2017-01-07
      • 2023-03-12
      • 2022-01-14
      相关资源
      最近更新 更多