Reference·Java SDK · nl.bimbase.bimworks.sdkJava

AuthApi

Java SDK: the Auth - Authentication operations, 13 methods, each with its parameters, result and a complete example.

Java SDK · nl.bimbase.bimworks.sdk.api · class · 13 methods

Authentication and authorization related calls such as for logging in and creating authentication tokens.

Construct it with the client of the connect step: new AuthApi(client). Each method is one operation of the API part, where it runs on its page.

MethodOperationDescription
createAnonymousTokenCreateAnonymousTokenCreate an anonymous token, for using BIM.works without an account
createApiTokenCreateApiTokenCreate an API token
createNodesTokenCreateNodesTokenCreate a new token, based on a set of Nodes
createRecursiveNodeTokenCreateRecursiveNodeTokenCreate a new token, based on a Node
createVersionsTokenCreateVersionsTokenCreate a new token, based on a set of Versions
deleteApiTokenDeleteApiTokenRevoke an API token
getSessionGetSessionDescribe the session behind the bearer token
listApiTokensListApiTokensList API tokens
loginAnonymousLoginAnonymousSign in without an account
loginWithAnonymousTokenLoginWithAnonymousTokenLogin using an anonymous token ("at-" prefixed)
loginWithApiTokenLoginWithApiTokenLogin using an API Token
loginWithUsernamePasswordLoginWithUsernamePasswordLogin using username/password, this can be used for testing.
updateApiTokenUpdateApiTokenChange an API token

createAnonymousToken#

Java#
public CreateAnonymousTokenResult createAnonymousToken(CreateAnonymousTokenRequest createAnonymousTokenRequest) throws ApiException

Create an anonymous token, for using BIM.works without an account. Creates an anonymous token together with its own base Node and user feature set. No authentication is required, but the feature must be enabled on the instance (features.anonymous_tokens). The returned token (always prefixed with "at-") is shown exactly once and cannot be recovered: when it is lost, nothing in the anonymous "account" is accessible anymore, by design. Use LoginWithAnonymousToken to exchange the token for an auth object.

OperationCreateAnonymousToken · POST /openapi/auth/CreateAnonymousToken
Scopenone: callable before logging in

Parameters#

NameTypeDescription
createAnonymousTokenRequestCreateAnonymousTokenRequestoptionalThe request: its properties are those of the model, its JSON that of CreateAnonymousToken's request body.

Returns#

CreateAnonymousTokenResult — The anonymous token was created. The token is returned exactly once and can never be retrieved again.

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.CreateAnonymousTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works (CreateAnonymousToken needs no login)
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");

        // 2. The request
        CreateAnonymousTokenRequest request = client.getObjectMapper().readValue("""
                {
                  "identifier": ""
                }
                """, CreateAnonymousTokenRequest.class);

        // 3. The call
        var result = new AuthApi(client).createAnonymousToken(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

createApiToken#

Java#
public ApiTokenSecret createApiToken(CreateApiTokenRequest createApiTokenRequest) throws ApiException

Create an API token. A long-lived token rooted at a folder, for a platform that provisions one per customer or a job that runs unattended. The secret is answered once and cannot be recovered; store it. Callable with an account session only: another API token, a delegated token or a workspace token is refused with CREDENTIAL_CREATION_NOT_ALLOWED.

OperationCreateApiToken · POST /openapi/auth/CreateApiToken
Scopeadmin:write, tokens:issue

Parameters#

NameTypeDescription
createApiTokenRequestCreateApiTokenRequestrequiredThe request: its properties are those of the model, its JSON that of CreateApiToken's request body.

Returns#

ApiTokenSecret — The new token, with its secret

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.CreateApiTokenRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        CreateApiTokenRequest request = client.getObjectMapper().readValue("""
                {
                  "name": "Customer 42 uploads",
                  "node_uuid": "0f1e2d3c-4b5a-4968-8776-655443322110",
                  "scopes": [
                    "fs:read",
                    "model:upload"
                  ],
                  "expires_on": "2027-06-30"
                }
                """, CreateApiTokenRequest.class);

        // 3. The call
        var result = new AuthApi(client).createApiToken(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

createNodesToken#

Java#
public AuthResult createNodesToken(CreateNodesTokenRequest createNodesTokenRequest) throws ApiException

Create a new token, based on a set of Nodes. A NodesToken gives access to a provided set of Nodes. This access does not recurse into sub Nodes. It does give access to any Version on any of the Nodes, at the time of creating the token, but also in the future.

OperationCreateNodesToken · POST /openapi/auth/CreateNodesToken
Scopetokens:issue

Parameters#

NameTypeDescription
createNodesTokenRequestCreateNodesTokenRequestrequiredThe request: its properties are those of the model, its JSON that of CreateNodesToken's request body.

Returns#

AuthResult — Generic auth response, which can be plugged into other clients (for example the Js SDK)

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.CreateNodesTokenRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        CreateNodesTokenRequest request = client.getObjectMapper().readValue("""
                {
                  "expires_seconds": 0,
                  "node_uuids": [
                    "00000000-0000-0000-0000-000000000000"
                  ],
                  "tasks": [
                    ""
                  ],
                  "scopes": [
                    "fs:read"
                  ],
                  "ip_addresses": [
                    ""
                  ],
                  "lock_to_called_ip": false,
                  "response_format": "auth"
                }
                """, CreateNodesTokenRequest.class);

        // 3. The call
        var result = new AuthApi(client).createNodesToken(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

createRecursiveNodeToken#

Java#
public AuthResult createRecursiveNodeToken(CreateRecursiveNodeTokenRequest createRecursiveNodeTokenRequest) throws ApiException

Create a new token, based on a Node.

OperationCreateRecursiveNodeToken · POST /openapi/auth/CreateRecursiveNodeToken
Scopetokens:issue

Parameters#

NameTypeDescription
createRecursiveNodeTokenRequestCreateRecursiveNodeTokenRequestrequiredThe request: its properties are those of the model, its JSON that of CreateRecursiveNodeToken's request body.

Returns#

AuthResult — Generic auth response, which can be plugged into other clients (for example the Js SDK)

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.CreateRecursiveNodeTokenRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        CreateRecursiveNodeTokenRequest request = client.getObjectMapper().readValue("""
                {
                  "expires_seconds": 0,
                  "node_uuid": "00000000-0000-0000-0000-000000000000",
                  "tasks": [
                    ""
                  ],
                  "scopes": [
                    "fs:read"
                  ],
                  "ip_addresses": [
                    ""
                  ],
                  "lock_to_called_ip": false,
                  "response_format": "auth"
                }
                """, CreateRecursiveNodeTokenRequest.class);

        // 3. The call
        var result = new AuthApi(client).createRecursiveNodeToken(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

createVersionsToken#

Java#
public AuthResult createVersionsToken(CreateVersionsTokenRequest createVersionsTokenRequest) throws ApiException

Create a new token, based on a set of Versions.

OperationCreateVersionsToken · POST /openapi/auth/CreateVersionsToken
Scopetokens:issue

Parameters#

NameTypeDescription
createVersionsTokenRequestCreateVersionsTokenRequestrequiredThe request: its properties are those of the model, its JSON that of CreateVersionsToken's request body.

Returns#

AuthResult — Generic auth response, which can be plugged into other clients (for example the Js SDK)

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.CreateVersionsTokenRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        CreateVersionsTokenRequest request = client.getObjectMapper().readValue("""
                {
                  "expires_seconds": 0,
                  "version_uuids": [
                    "<version uuid of the first demo model>"
                  ],
                  "tasks": [
                    ""
                  ],
                  "scopes": [
                    "fs:read"
                  ],
                  "ip_addresses": [
                    ""
                  ],
                  "lock_to_called_ip": false,
                  "response_format": "auth"
                }
                """, CreateVersionsTokenRequest.class);

        // 3. The call
        var result = new AuthApi(client).createVersionsToken(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

deleteApiToken#

Java#
public void deleteApiToken(DeleteApiTokenRequest deleteApiTokenRequest) throws ApiException

Revoke an API token. The token stops working at once. Needs write rights on its Node while that Node exists, and the caller must be the token's creator, an admin of its organization or a super admin; another member is refused (403 NON_AUTHORIZED_TASK). Callable with an account session or an API token, not with a delegated or workspace token.

OperationDeleteApiToken · POST /openapi/auth/DeleteApiToken
Scopeadmin:write

Parameters#

NameTypeDescription
deleteApiTokenRequestDeleteApiTokenRequestrequiredThe request: its properties are those of the model, its JSON that of DeleteApiToken's request body.

Returns#

Nothing: the operation answers without a body (The token is revoked).

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.DeleteApiTokenRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        DeleteApiTokenRequest request = client.getObjectMapper().readValue("""
                {
                  "uuid": "<version uuid of the first demo model>"
                }
                """, DeleteApiTokenRequest.class);

        // 3. The call
        new AuthApi(client).deleteApiToken(request);

        // 4. The result
        // (DeleteApiToken answers no content: the call returns once it succeeded and throws an ApiException otherwise)
        System.out.println("Done");
    }
}

getSession#

Java#
public Session getSession() throws ApiException

Describe the session behind the bearer token. What the presented credential is: its kind, when it expires, the scopes it grants (absent when it is unscoped, as an account session is), the Node it is rooted at, and, when it belongs to an account and grants account:read, that account. A nodes token (CreateNodesToken) or a versions token (CreateVersionsToken) has no root Node: it answers the Nodes (node_uuids) or Versions (version_uuids) it names instead. A credential that is no longer valid (expired, signed out, its account removed) answers 401, so this is also the check that a stored token still works.

OperationGetSession · POST /openapi/auth/GetSession
Scopeany login

Parameters#

None: the operation takes no request.

Returns#

Session — The session

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        // (GetSession takes no request)

        // 3. The call
        var result = new AuthApi(client).getSession();

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

listApiTokens#

Java#
public List<ApiToken> listApiTokens(ListApiTokensRequest listApiTokensRequest) throws ApiException

List API tokens. The active API tokens rooted at a Node (node_uuid, which needs read rights on it), or without node_uuid those of the caller's organization, which only a super admin or the organization's creator lists (403 NON_AUTHORIZED_TASK for any other member). The secret is never listed: last_four shows its end. Expired tokens are listed with their expires_on.

OperationListApiTokens · POST /openapi/auth/ListApiTokens
Scopeadmin:read

Parameters#

NameTypeDescription
listApiTokensRequestListApiTokensRequestoptionalThe request: its properties are those of the model, its JSON that of ListApiTokens's request body.

Returns#

List<ApiToken> — The tokens

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.ListApiTokensRequest;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        ListApiTokensRequest request = client.getObjectMapper().readValue("""
                {
                  "node_uuid": "00000000-0000-0000-0000-000000000000"
                }
                """, ListApiTokensRequest.class);

        // 3. The call
        var result = new AuthApi(client).listApiTokens(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

loginAnonymous#

Java#
public AuthResult loginAnonymous(LoginAnonymousRequest loginAnonymousRequest) throws ApiException

Sign in without an account. An anonymous session: it reaches only the operations that need no credential, unless the instance allows anonymous use (features.allow_anonymous_use). It is what the SDKs' anonymous client uses. Not to be confused with anonymous tokens (CreateAnonymousToken, LoginWithAnonymousToken), which own a Node of their own.

OperationLoginAnonymous · POST /openapi/auth/LoginAnonymous
Scopenone: callable before logging in

Parameters#

NameTypeDescription
loginAnonymousRequestLoginAnonymousRequestoptionalThe request: its properties are those of the model, its JSON that of LoginAnonymous's request body.

Returns#

AuthResult — The anonymous session

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.LoginAnonymousRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works (LoginAnonymous needs no login)
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");

        // 2. The request
        LoginAnonymousRequest request = client.getObjectMapper().readValue("""
                {
                  "response_format": "auth"
                }
                """, LoginAnonymousRequest.class);

        // 3. The call
        var result = new AuthApi(client).loginAnonymous(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

loginWithAnonymousToken#

Java#
public AuthResult loginWithAnonymousToken(LoginWithAnonymousTokenRequest loginWithAnonymousTokenRequest) throws ApiException

Login using an anonymous token ("at-" prefixed).

OperationLoginWithAnonymousToken · POST /openapi/auth/LoginWithAnonymousToken
Scopenone: callable before logging in

Parameters#

NameTypeDescription
loginWithAnonymousTokenRequestLoginWithAnonymousTokenRequestrequiredThe request: its properties are those of the model, its JSON that of LoginWithAnonymousToken's request body.

Returns#

AuthResult — The login attempt succeeded

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.LoginWithAnonymousTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works (LoginWithAnonymousToken needs no login)
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");

        // 2. The request
        LoginWithAnonymousTokenRequest request = client.getObjectMapper().readValue("""
                {
                  "token": "",
                  "response_format": "auth"
                }
                """, LoginWithAnonymousTokenRequest.class);

        // 3. The call
        var result = new AuthApi(client).loginWithAnonymousToken(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

loginWithApiToken#

Java#
public AuthResult loginWithApiToken(LoginWithApiTokenRequest loginWithApiTokenRequest) throws ApiException

Login using an API Token.

OperationLoginWithApiToken · POST /openapi/auth/LoginWithApiToken
Scopenone: callable before logging in

Parameters#

NameTypeDescription
loginWithApiTokenRequestLoginWithApiTokenRequestrequiredThe request: its properties are those of the model, its JSON that of LoginWithApiToken's request body.

Returns#

AuthResult — The login attempt succeeded

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works (LoginWithApiToken needs no login)
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");

        // 2. The request
        LoginWithApiTokenRequest request = client.getObjectMapper().readValue("""
                {
                  "token": "<your API token>"
                }
                """, LoginWithApiTokenRequest.class);

        // 3. The call
        var result = new AuthApi(client).loginWithApiToken(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

loginWithUsernamePassword#

Java#
public AuthResult loginWithUsernamePassword(LoginWithUsernamePasswordRequest loginWithUsernamePasswordRequest) throws ApiException

Login using username/password, this can be used for testing. For production use we advise LoginWithApiToken

OperationLoginWithUsernamePassword · POST /openapi/auth/LoginWithUsernamePassword
Scopenone: callable before logging in

Parameters#

NameTypeDescription
loginWithUsernamePasswordRequestLoginWithUsernamePasswordRequestrequiredThe request: its properties are those of the model, its JSON that of LoginWithUsernamePassword's request body.

Returns#

AuthResult — The login attempt succeeded. The token is also returned in the Authorization response header.

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.LoginWithUsernamePasswordRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works (LoginWithUsernamePassword needs no login)
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");

        // 2. The request
        LoginWithUsernamePasswordRequest request = client.getObjectMapper().readValue("""
                {
                  "username": "",
                  "password": "",
                  "response_format": "auth"
                }
                """, LoginWithUsernamePasswordRequest.class);

        // 3. The call
        var result = new AuthApi(client).loginWithUsernamePassword(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}

updateApiToken#

Java#
public ApiToken updateApiToken(UpdateApiTokenRequest updateApiTokenRequest) throws ApiException

Change an API token. Changes the fields that are passed; the others stay as they are. Changing scopes needs tokens:issue as well, and so does rotate_secret, which replaces the secret (for a rotation from a vault) and answers the new one once in token. Callable with an account session, or with an API token for that token itself (another token is refused with CREDENTIAL_CREATION_NOT_ALLOWED before anything changes); not with a delegated or workspace token. An API token moves its own expires_on earlier, never later. Needs write rights on the token's Node, and the caller must be the token's creator, an admin of its organization or a super admin: a token acts as the account that created it, so another member is refused (403 NON_AUTHORIZED_TASK).

OperationUpdateApiToken · POST /openapi/auth/UpdateApiToken
Scopeadmin:write

Parameters#

NameTypeDescription
updateApiTokenRequestUpdateApiTokenRequestrequiredThe request: its properties are those of the model, its JSON that of UpdateApiToken's request body.

Returns#

ApiToken — The token as it is now; token holds the new secret after rotate_secret

Example#

Java#
import nl.bimbase.bimworks.sdk.api.AuthApi;
import nl.bimbase.bimworks.sdk.client.ApiClient;
import nl.bimbase.bimworks.sdk.model.Auth;
import nl.bimbase.bimworks.sdk.model.LoginWithApiTokenRequest;
import nl.bimbase.bimworks.sdk.model.UpdateApiTokenRequest;

public class Example {
    public static void main(String[] args) throws Exception {
        // 1. Connect to BIM.works and log in with your API token
        ApiClient client = new ApiClient();
        client.updateBaseUri("https://bim.works/openapi");
        Auth auth = new AuthApi(client)
                .loginWithApiToken(new LoginWithApiTokenRequest().token("<your API token>"))
                .getAuth();
        client.setRequestInterceptor(builder -> builder.setHeader("Authorization", "Bearer " + auth.getBase64()));

        // 2. The request
        UpdateApiTokenRequest request = client.getObjectMapper().readValue("""
                {
                  "uuid": "<version uuid of the first demo model>",
                  "name": "",
                  "scopes": {},
                  "expires_on": "",
                  "cors_enabled_domains": {},
                  "only_cors_enabled_addresses": false,
                  "white_listed_ip_addresses": {},
                  "only_white_listed_ip_addresses": false,
                  "rotate_secret": false
                }
                """, UpdateApiTokenRequest.class);

        // 3. The call
        var result = new AuthApi(client).updateApiToken(request);

        // 4. The result
        System.out.println(client.getObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(result));
    }
}