我正在连接到auth forge,成功获得了access_token:
$.ajax({
type: "POST",
url: "https://developer.api.autodesk.com/authentication/v1/authenticate",
data: "client_id="+client_id+"&client_secret="+client_secret+"&grant_type=client_credentials&scope=data:read",
success: success,
dataType: "json"
});
然后尝试从bim 360文档中列出项目,则返回
{“ developerMessage”:“令牌没有此请求的特权。”,“ moreInfo”:“ https://forge.autodesk.com/en/docs/oauth/v2/developers_guide/error_handling/”,“ errorCode” :“ AUTH-010”}
我已经在Forge上创建了一个应用,并在bim 360文档上激活了“添加自定义集成”,我还缺少什么?
$.ajax({
type: "GET",
url: "https://developer.api.autodesk.com/hq/v1/accounts/"+conta_id+"/projects",
beforeSend: function(xhr) {
xhr.setRequestHeader("Authorization", "Bearer "+token);
},
processData: false,
success: success_projects,
error: function(){
console.log("Cannot get data");
},
dataType: "json"
});
提前致谢。
我认为这是由于范围有限而引起的问题,请按端点https://forge.autodesk.com/zh-CN/docs/bim360/v1/reference/http/projects-GET列出BIM 360帐户中的所有项目/,你需要“ account:read”范围,但在你的代码中看不到该范围。请确保至少添加此范围,然后重试。
谢谢你。它解决了我的问题。