Search code examples
autodesk-forgeautodeskforgeautodesk-model-derivative

Get Three legged token with Node js Autodesk Forge


Is there a simpler way to generate a three legged token only using Node js. I have used the method in the [1]: https://learnforge.autodesk.io/#/oauth/3legged/nodejs, but I am looking for a simpler method, that just gives me the token.


Solution

  • The standard workflow for a 3-legged OAuth token (not just for Forge but for any OAuth 2.0 provider) is typically:

    1. You redirect the user to Autodesk login form
    2. You wait for a callback from the Autodesk login form (assuming the user logged in successfully), and retrieve a temporary code
    3. You exchange the temporary code for an actual access token (and a refresh token)

    This process is explained in the docs as well.

    Another option that is perhaps a bit simpler is using the "implicit grant" where the step 3 is basically skipped, and the access token is included directly in the callback. The downside of this approach is that you do not receive the refresh token.