Autodesk-Forge / forge-api-nodejs-client

Forge Node.js SDK: Provides Node.js SDK to help you easily integrate Forge REST APIs into the application
Apache License 2.0
122 stars 87 forks source link

Problem with HubsApi #24

Closed nasushkov closed 7 years ago

nasushkov commented 7 years ago

Hi, I have a trouble with https://developer.api.autodesk.com/project/v1/hubs/project/v1/hubs Right now I'm testing this endpoint in Postman with the following headers:

Content-Type: application/vnd.api+json Accept: application/json, application/vnd.api+json Authorization: Bearer {{AccessToken}}

Unfortunately, I've got an error with 403 status code, when sending this request:

{ "jsonapi": { "version": "1.0" }, "errors": [ { "status": "403", "code": "BIM360DM_ERROR", "title": "Unable to get hubs from BIM360DM US.", "detail": "You don't have permission to access this API" }, { "status": "403", "code": "BIM360DM_ERROR", "title": "Unable to get hubs from BIM360DM EMEA.", "detail": "You don't have permission to access this API" } ] }

Other API calls ( https://developer.api.autodesk.com/modelderivative/v2/designdata/formats, for instance, are working properly)

What can be the reason for this?

gregra81 commented 7 years ago

@nasushkov - How exactly did you obtain your access token? What scopes have you used?

nasushkov commented 7 years ago

@gregra81 Here it is: POST https://developer.api.autodesk.com/authentication/v1/authenticate

Headers: Content-Type: application/x-www-form-urlencoded

Body: grant_type: client_credentials client_id: {{ConsumerKey}} client_secret: {{ConsumerSecret}} scope: data:read data:write data:create data:search bucket:create bucket:read bucket:update bucket:delete code:all account:read account:write user-profile:read viewables:read

augustogoncalves commented 7 years ago

For BIM 360 Hubs you need a 3-legged token, obtained from the user (via login page). The 2-legged workflow works for BIM 360 HQ (meaning to access admin endpoints listed here)

gregra81 commented 7 years ago

@nasushkov - This is how you obtain a 3-legged token: https://github.com/Autodesk-Forge/forge-api-nodejs-client#3-legged-token

nasushkov commented 7 years ago

Thanks, @augustogoncalves, @gregra81 with 3-legged it works. But is there any way to access user data with 2-legged token? I ask this because my current workflow is the following: user uploads files to the project and then my service processes them in the background. So, is there any way to give an access to this data with 2-legged or I still need to obtain user permission somehow?

mrdaliri commented 4 years ago

@nasushkov: Did you find a solution with 2-legged authentication? I'm in the same boat.

cyrillef commented 4 years ago

2 legged is working, but you need 3 things to have it work properly.

a- if your BIM360 account is less than 100 users, you need to ask the API to be enabled on that account - sending an email to bim360appsactivations@autodesk.com for activating the API. b- you need to provision your Forge client ID on the BIM360 account c- when using 2 legged, you need to pass an user' oxygen ID in the header. When using the API, add a xuserid parameter. See here on the implementation detail.

I am using 2 and 3 legged in the node-red project without any issue. However, note that 2 legged will not give you the same level of access compared to 3legged.

klompenrunner commented 1 year ago

This is the most up to date answer now: https://aps.autodesk.com/blog/errors-when-retrieving-hubs