Search code examples
oauthautodesk-forge

Communicating with APS ACC Asset module automatically


We have information in a SharePoint list that I am trying to lift over to the asset module in ACC. I am almost there but ran into an issue, it seems I can only connect to ACC assets via a 3-legged token. I would love to not have to do this workflow manually since the update will have to be every night and it is quite some information that needs to be lifted over.

I am building the script in Azure logic apps, and just started looking at creating my own connector to somehow get around the issue of the 3-legged token. But maybe someone here on stackoverflow had some luck in this? It would be great if the Azure script could do this all on itself without a user in the middle.

Thankful for any and all help!


Solution

  • You're correct. Unfortunately, there is no 2LO (2-legged Oauth) support on most BIM360/ACC API, including Assets.

    However, The manual login only requires once before you have the APS access token and refresh token. Once you have a pair of APS access token and refresh token, you can renew the access token with the refresh token without doing the manual login. Here is an example from our nodejs tutorial. You can do similar in your app's background.

    if (expires_at < Date.now()) {
        const internalCredentials = await internalAuthClient.refreshToken({ refresh_token });
        const publicCredentials = await publicAuthClient.refreshToken(internalCredentials);
        req.session.public_token = publicCredentials.access_token;
        req.session.internal_token = internalCredentials.access_token;
        req.session.refresh_token = publicCredentials.refresh_token;
        req.session.expires_at = Date.now() + internalCredentials.expires_in * 1000;
    }
    

    Here are some references to the refresh token: