在最近使用extract.autodesk.io模块解决的帖子之后(SVF 模型衍生品下载为(几乎)空的 ZIP 文件(Autodesk Forge)),我仍然难以使用官方 forge 下载 SVF 模型衍生品-apis模块,在 2-leged 上下文中。
这是我试图实现的最小示例:
var ForgeSDK = require("forge-apis");
/* The next four lines are filled with my credentials and URN values
* (this shouldn't be the problem, since getting the manifest for the URN
* is performed successfully) */
var client_id = "...";
var client_secret = "...";
var urn = "...";
var derivative_urn = "...";
var derivatives = new ForgeSDK.DerivativesApi();
var autoRefresh = true;
var oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(client_id,
client_secret, [
"data:read", "data:write", "bucket:read", "bucket:write"
], autoRefresh);
oAuth2TwoLegged.authenticate().then(function(credentials) {
derivatives.getDerivativeManifest(urn, derivative_urn, {}, credentials, oAuth2TwoLegged).then(function(content) {
console.log(content);
}).catch(function(err) {
if (err) {
console.log(err);
}
})
});
我收到以下错误:{ statusCode: 401, statusMessage: 'Unauthorized' }。是范围问题吗?
提前非常感谢!
PS:我知道extract.autodesk.io提供了一个很好的方法来做到这一点,但我觉得使用气泡对象在另一个上下文中转置并不是那么简单。forge -apis模块应该无缝地完成这项工作(或者我错过了一些东西)。
更新:按照 Augusto 的建议,我使用了最基本的命令(即 cUrl)从 IFC 文件中下载信息。下面的前两个命令成功运行(下载清单和 PNG 屏幕截图文件)。SVF 的下载似乎也可以正常工作,只是 ZIP 文件只包含两个 JSON 文件(manifest.json 和 metadata.json),以及三个空目录(几何、材质、场景)。
这是代码:
# Get manifest for the IFC file
curl -X "GET" -H "Authorization: Bearer $TOKEN" -v "https://developer.api.autodesk.com/modelderivative/v2/designdata/$URN_IFC/manifest" > manifest.json
# Get a PNG related to the IFC file
curl -X "GET" -H "Authorization: Bearer $TOKEN" -v "https://developer.api.autodesk.com/modelderivative/v2/designdata/$URN_IFC/manifest/$URN_PNG" > image.png
# Get the SVF converted from the IFC file
curl -X "GET" -H "Authorization: Bearer $TOKEN" -v "https://developer.api.autodesk.com/modelderivative/v2/designdata/$URN_IFC/manifest/$URN_SVF" > output.zip
任何想法?