Search code examples
autodesk-forgerevit-apiautodesk-data-managementautodesk-bim360

Can I use the same SSO session in a Revit add-in for my own Forge API usage?


I am currently working on an extension to a Revit add-in, which pulls BIM360 cloud models to use in some processing. With the Forge API Client for C# I'm now retrieving the hubs, projects and files which the user is allowed to access.

My gripe is with the fact that the user has been signed into Autodesk from basically the first moment Revit is launched, while I'm having to prompt the user to sign in a second time with a CefSharp modal browser dialog with the exact same sign-in, accept the Forge application's permission requests, and loop back to the add-in.

It feels incredibly superfluous to have to make the user sign in while he's signed in. Although I try to prompt for authentication as little as possible, refreshing tokens whenever I can, it will still come down to prompting every time I'm beyond the token's expiration time. Also, if the user ends up filling a different user to the one Revit is currently signed in to, he can select files which are potentially not allowed to be opened by the session in Revit.

Is there a way to either:

  • ... use the same sign in as Revit does to shorten the process (as it's single sign on already)?
  • ... prevent the user from having to re-authenticate every single time to make it less tedious?

Solution

  • Unfortunately, you cannot use Revit's authentication (access_token). Just like you (and your app), Revit uses a Forge Client ID & Secret, with a specific set of permissions and scopes, and can only be used by Revit.

    Your app needs to authenticate at least once. After that, you can use the refresh_token to avoid re-entering credentials.