简体   繁体   中英

403 error in calling DerivativeApi of Autodesk Forge

Autodesk Forge 's DerivativeApi is not working with my client id and secret. Apis returns unauthorized error, { statusCode: 403, statusMessage: 'Unauthorized' } .

But they works with the sample's client id/secret (from https://github.com/Autodesk-Forge/forge-api-nodejs-client/blob/master/samples/dmSample.js ).

Is there any limitation for calling DerivativeApi (for translating) with free account? or should I do something?

Here is the sample code...

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);

Thanks

First, and extremely important, NEVER share your ID & Secret. If the above is your correct one, please create a new secret (to invalidate this).

Now the ID & Secret should work for any sample, just make sure you activated the APIs for it. On your app, select Model Derivative API on the screen, if not available, please review this article .

Finally, the code sample above is not actually calling Model Derivative. If so, note that files uploaded into one account are not accessible from other accounts, and URNs are unique.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM