调用Autodesk Forge的DerivativeApi时出错403错误

问题描述 投票:0回答:1

Autodesk Forge的DerivativeApi无法使用我的客户端ID和密码。 Apis返回未经授权的错误,{statusCode:403,statusMessage:'Unauthorized'}。

但是他们使用样本的客户端id / secret(来自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);

谢谢

javascript node.js autodesk-forge unauthorized
1个回答
0
投票

首先,非常重要的是,永远不要分享你的身份和秘密。如果以上是正确的,请创建一个新秘密(使此无效)。

现在,ID&Secret应适用于任何样本,只需确保为其激活API。在您的应用上,选择屏幕上的Model Derivative API,如果没有,请选择please review this article

最后,上面的代码示例实际上并没有调用Model Derivative。如果是这样,请注意,无法从其他帐户访问上载到一个帐户的文件,并且URN是唯一的。

© www.soinside.com 2019 - 2024. All rights reserved.