Auth tokens are different than API Tokens. API Tokens can be created in BIM.works and are stored in the database (hashed of course). API Tokens are valid until they are removed, so they can be valid for a long time. API Token are linked to Nodes and give read and/or write access on all Nodes and Versions below that Node.

Auth Tokens are:

The main use case for Auth Tokens is to delegate specific and limited authorization to any unsafe context, such as a browser. Your Application Backend has all information about what users can do what actions (API calls) on what data (models). Therefore the Backend Application asks BIM.works for short-lived tokens that it can then pass onto the Frontend Application (Browser).

tmptokensgravicon.drawio.png

NodesToken

A NodesToken can be about a set of ‣s. Keep in mind that users can upload multiple ‣s to a Node and any user with a NodesToken can see all versions of the respective Node.

VersionsToken

A VersionsToken is about a set of ‣s. In many cases a VersionsToken makes more sense than using a NodesToken; It gives you more control over which models exactly a user can see. Versions can be in different Nodes.

RecursiveNodeToken

A RecursiveNodeToken allows you to select only one ‣. However all the Nodes/Versions below this Node will be visible to the user. Use this type of token with caution!

Creating Auth Tokens

Tokens can be created after you have authenticated yourself, either with a user account, or with an API Token.

Java SDK

BimWorksClient client = ...;

// To create a NodesToken
ObjectNode authToken= client.tokens.createNodesToken(nodeUuids, Duration.ofMinutes(10), Set.of("DownloadGeometry2DNew", "TableExport2"), Set.of("123.456.789.123"));

// To create a VersionsToken
ObjectNode authToken= client.tokens.createVersionsToken(versionUuids, Duration.ofMinutes(10), Set.of("DownloadGeometry2DNew", "TableExport2"), Set.of("123.456.789.123"));

// To create a RecursiveNodeToken
ObjectNode authToken= client.tokens.createRecursiveNodeToken(nodeUuid, Duration.ofMinutes(10), Set.of("DownloadGeometry2DNew", "TableExport2"), Set.of("123.456.789.123"));

// The returned "authToken" is a piece of JSON. This is what you forward to the browser

.Net SDK

BimWorksClient bimWorksClient = ...;

bimWorksClient.Tokens.CreateNodesTokenResponse(new CreateNodesTokenRequest(nodeUuids, Collections.CreateHashSet("Query2", "GetNodeByUuid"), TimeSpan.FromSeconds(3)));

bimWorksClient.Tokens.CreateRecursiveNodeToken(...

bimWorksClient.Tokens.CreateVersionsToken(...