【发布时间】:2018-06-04 22:14:27
【问题描述】:
Autodesk Forge 的 DerivativeApi 无法使用我的客户端 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