【问题标题】:403 error in calling DerivativeApi of Autodesk Forge调用 Autodesk Forge 的 DerivativeApi 时出现 403 错误
【发布时间】:2018-06-04 22:14:27
【问题描述】:

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

但它们使用示例的客户端 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);

谢谢

【问题讨论】:

    标签: javascript node.js autodesk-forge unauthorized


    【解决方案1】:

    首先,非常重要的是,切勿分享您的 ID 和秘密。如果以上内容正确,请创建一个新的secret(使之无效)。

    现在 ID 和 Secret 应该适用于任何示例,只需确保为它激活了 API。在您的应用上,选择屏幕上的Model Derivative API,如果不可用,请选择please review this article

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

    【讨论】:

      猜你喜欢
      • 2021-10-16
      • 2023-03-12
      • 2020-01-27
      • 2019-10-07
      • 2019-02-16
      • 2013-07-04
      • 2019-04-17
      • 2019-07-21
      • 2017-03-25
      相关资源
      最近更新 更多