Autodesk Forge的DerivativeApi不使用我的客户端id和机密。Apis返回未经授权的错误,{ statusCode: 403,statusMessage:‘未经授权’}。
但是它们使用示例的客户机id/机密(来自https://github.com/Autodesk-Forge/forge-api-nodejs-client/blob/master/samples/dmSample.js)。
用免费帐户调用DerivativeApi (翻译)有什么限制吗?还是我该做点什么?
这是样本代码..。
var ForgeSDK = require('forge-apis');
// TODO - insert your CLIENT_ID and CLIENT_SECRET
// Below id/secret from the sample are working, but mine is not.
var CLIENT_ID = 'wmizntnpzCJxPGF9lxsIiTZGbGO2cJqw',
CLIENT_SECRET = 'g5IPJwvhOHcrdbFy';
var derivativesApi = new ForgeSDK.DerivativesApi();
// Initialize the 2-legged oauth2 client
var oAuth2TwoLegged = new ForgeSDK.AuthClientTwoLegged(CLIENT_ID, CLIENT_SECRET,
['data:write', 'data:read', 'bucket:read', 'bucket:update', 'bucket:create'], true);
function defaultHandleError(err) {
console.error('\x1b[31m Error:', err, '\x1b[0m');
}
oAuth2TwoLegged.authenticate().then(function (credentials) {
console.log("**** Got Credentials", credentials);
derivativesApi.getFormats({}, oAuth2TwoLegged, oAuth2TwoLegged.getCredentials()).then(res => {
console.log(res);
}, defaultHandleError);
}, defaultHandleError);谢谢
发布于 2017-12-22 12:16:05
首先,也是非常重要的是,从不共享您的ID和秘密。如果上面的内容是正确的,请创建一个新的机密(以使其无效)。
现在,ID和秘密应该适用于任何示例,只需确保您激活了它的API。在您的应用程序上,在屏幕上选择Model Derivative API,如果不可用,选择请回顾这篇文章。
最后,上面的代码示例实际上并不是调用Model导数。如果是这样的话,请注意上传到一个帐户的文件不能从其他帐户访问,并且URN是唯一的。
https://stackoverflow.com/questions/47938443
复制相似问题