I downloaded the sample project file provided by Autodesk Forge to implement Design Automation from here: https://github.com/Autodesk-Forge/learn.forge.designautomation/tree/nodejs
Issue: Getting Error in the DesignAutomation.js on the line code below. The error says 'Forbidden, Not authroized' although I had provided my forge app's token, key and the ngrok url.
let engines = await api.getEngines({ page: paginationToken });
I debugged and found that the above line of code is failing and going to the catch exception. Due to this error, I have the 'Select Engines' and 'Existing Activities' dropdown in the UI show up as empty.
Can someone help me with this issue? I'm new with Autodesk Forge and WebAPI, so I'm not able to figure out how to go about this. Thanks.
I think the problem is in the source code, but you can fix it.
The provided source code assumes that you will not change your nickname. If you don't change your nickname, it will default to your ClientID and the sample code uses this assumption. In the source code, line 57, you will see that:
static get NickName () {
return (config.credentials.client_id);
}
it assumes that your nickname matches the client_id.
Check what is your current nickname by running in terminal (or Postman/Insomnia) the following:
curl 'https://developer.api.autodesk.com/da/us-east/v3/forgeapps/me' \
--header 'Authorization: Bearer '$TOKEN
If the provided result doesn't match your ClientId, you can be sure that this is the source of trouble.
In this case, to solve the problem, there are two approaches:
Change the code of the NickName function (within the source code) to retrieve the nickname (using the above call), instead of just getting the ClientID.
Reset your nickname, which actually means deleting the activities, bundles and all user stuff. The way to do it is by running:
curl --request DELETE 'https://developer.api.autodesk.com/da/us-east/v3/forgeapps/me'
--header 'Authorization: Bearer `$TOKEN
This will reset your nickname to your ClientID and the code should work fine.