2

I'm trying to create an app that create some webhooks to catch Autodesk Data Management API events.

When I create the app with a personal account for testing, it works fine. I get the token and then, I use it to create the webhook. But when I change the client id and the client secret to use the bussiness account where I need to work, it fails. The app is created and integrated by the account manager, and I get the token well, with the correct scopes (the same that I'm using with my personal account that works). The error is 403, FORBIDEN ACCESS.

I'm testing with this cUrl commands: 1. GET THE TOKEN:

curl -v 'https://developer.api.autodesk.com/authentication/v1/authenticate' \
  -X 'POST' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'client_id=<HERE_THE_CLIENT_ID>&client_secret=<HERE_THE_CLIENT_SECRET>&grant_type=client_credentials&scope=data:read%20data:create%20data:write%20user-profile:read%20viewables:read%20data:search%20account:read%20bucket:create%20bucket:read'
  1. CREATE THE WEBHOOK:
curl -X 'POST' -v 'https://developer.api.autodesk.com/webhooks/v1/systems/data/events/dm.version.added/hooks' -H 'Content-Type: application/json' \
 -H 'authorization: Bearer <TOKEN_OBTAINED>' -d '{"callbackUrl": "http://<URL>.ngrok.io/api/forge/hook/callback","scope": {"folder": <FOLDER_URN>},"hookAttribute": {"projectId": "b.<PROJECT_ID>"}}'

This is the error message I receive:

  "status" : 403,
  "code" : "FORBIDDEN_ERROR",
  "detail" : [ "Access denied for resource <FOLDER_URN> in scope <FOLDER_URN> that you are trying to create hook on." ]

2 Answers2

3

I solved it changing the header of the region in the request! Check this: https://forge.autodesk.com/blog/bim-360-docs-webhooks-data-events-european-data-center

0

Webhooks for Data Management folders require 3 legged tokens (i.e. it need user permission). See this nodejs sample.

Augusto Goncalves
  • 8,493
  • 2
  • 17
  • 44
  • But I'm working with a backend implementation, how can I implement a 3 legged token authentication in a backend service if I have to validate with the user? And why with another project and another ID and Secret IT works using 2 legged tokens? – Juan Jesús Padrón Hernández Oct 02 '19 at 08:22
  • I tried cloning the exmple and setting the ID and SECRET of the application that I have to integrate and I have the same 403 error. – Juan Jesús Padrón Hernández Oct 02 '19 at 08:44
  • Webhooks for Folders will only work with 3L, if you're still getting 403, it may be due to lack of user access permission to that folder – Augusto Goncalves Oct 02 '19 at 16:10
  • I'm creating Webhooks to catch events from all the project, so i'm using the root folder of the project. But if webhooks needs 3L I don't understand why it works in my own project... I'm with an admin account in both cases – Juan Jesús Padrón Hernández Oct 03 '19 at 09:03
  • You should be using `topFolders` and creating the hook for *Project Files* (or *Plans*) folder. – Augusto Goncalves Oct 03 '19 at 17:29
  • Yeah, I solved the problem! I have just read your post about regions, and the project that didn't works is im "EMEA" region. When I implemented my code, this post didnt exist. Thank you! (The solution: https://forge.autodesk.com/blog/bim-360-docs-webhooks-data-events-european-data-center ) – Juan Jesús Padrón Hernández Oct 04 '19 at 08:53