Search code examples
javascriptcross-domainautodesk-forge2-legged

Getting Forge 2-legged authentication using Cross request


I'm trying to create a simple html page to display a uploaded model to forge. For initialize the forge viewer it required the access-token. For request the access token I'm using the 2-legged oAuth on a Cross request(because I'm making the POST on different domain).But it keep getting error "No 'Access-Control-Allow-Origin' header is present on the requested resource". Please some one can tell me what should I do to get the acces-token successfully.


Solution

  • As you noticed, you cannot obtain a Forge Token via client-side scripting, it will throw this CORS error. This is by design.

    I would recommend a simple server-side authentication, it's quite direct to deploy this sample locally:

    1. Install NodeJS
    2. Download the project
    3. Set the variables with your ID & Secret
    4. Run the project