【发布时间】:2020-03-20 13:43:59
【问题描述】:
我们收到客户的询问,希望从我们的应用程序中启用 Autodesk 模型查看器。第一步是实现OAuth2身份验证(2条腿)。我遵循了 Forge Autodesk 教程,但这对我来说是全新的,我无法将其配置为工作。我从我们的应用程序发出http 请求(使用jQuery),传递client_id 和client_secret、grant_type 和一个范围。查看开发人员菜单 (F12) - 我可以看到请求正在访问他们的服务器并返回 access_token、过期时间、授权“Bearer”,状态为 200。到目前为止,一切都很好。
我知道现在我需要回调 API 并传递我收到的这个 access_token。这是我丢失的地方:控制台向我显示错误,Cross origin ...并且http请求的成功部分没有触发(在http请求成功部分我试图将用户重定向到我们刚刚收到的模型查看器url + access_token )。但它永远不会着火。正在挖掘论坛和教程,但找不到任何好的示例或解释我做错了什么。下面是我的代码示例:
$.post("https://developer.api.autodesk.com/authentication/v1/authenticate",
{
client_id: 'here_is_a_client_id',
client_secret: 'here_is_a_client_secret',
grant_type: 'client_credentials',
scope: 'viewables:read'
},
function(data, status){
console.log("Data: " + data);
window.location.href = 'https://viewer.autodesk.com/id/here_is_a_long_id_number&Authorization=Bearer&' + data;
});
高度赞赏任何帮助。此外,我尝试使用 Node.js 来遵循 Autodesk 教程,但同样,在看到 access_token 从他们的服务器返回后,无法进行回调并将此 access_token 附加到它。所有这些Authorization/Authentication/Tokens 的新手,所以无法弄清楚它的工作方式。提前致谢。
【问题讨论】:
标签: oauth-2.0 autodesk-forge autodesk-viewer autodesk