### Untitled No description -------------------------------- ### Create Service Account, Key, and Get Token (Python) Source: https://developer.doc.autodesk.com/bPlouYTd/cloud-platform-ssa-docs-main-460369/ssa/v1/tutorials/getting-started-with-ssa/about-this-walkthrough.html This Python script automates the creation of a service account (SSA), its associated key, and retrieves necessary credentials. It requires the 'requests' library and configuration of client IDs, secrets, and service account names. The script outputs the SSA email, service account ID, key ID, and private key. ```python # Install dependencies # > pip install requests import requests # Configuration APS_CLIENT_ID = "your_client_id" APS_SECRET_ID = "your_client_secret" FIRST_NAME = "service" # Service account first name LAST_NAME = "mycompany-filesync" # Service account last name BASE_URL = "https://developer.api.autodesk.com/authentication/v2" SCOPE_ADMIN = [ "application:service_account:read", "application:service_account:write", "application:service_account_key:write" ] # Get admin token using client credentials. def get_admin_token(): url = f"{BASE_URL}/token" data = { "grant_type": "client_credentials", "scope": " ".join(SCOPE_ADMIN) } response = requests.post(url, data=data, auth=(APS_CLIENT_ID, APS_SECRET_ID)) response.raise_for_status() return response.json()["access_token"] # Create a new service account with firstName, lastName, and concatenated name. def create_service_account(admin_token): url = f"{BASE_URL}/service-accounts" headers = {"Authorization": f"Bearer {admin_token}"} payload = { "name": f"{FIRST_NAME}-{LAST_NAME}", "firstName": FIRST_NAME, "lastName": LAST_NAME } response = requests.post(url, json=payload, headers=headers) if response.status_code != 200: print("Error creating service account:", response.text) response.raise_for_status() return response.json() # Create a key for the specified service account. def create_service_account_key(admin_token, service_account_id): url = f"{BASE_URL}/service-accounts/{service_account_id}/keys" headers = {"Authorization": f"Bearer {admin_token}"} response = requests.post(url, headers=headers) if response.status_code != 200: print("Error creating service account key:", response.text) response.raise_for_status() return response.json() def main(): admin_token = get_admin_token() account_data = create_service_account(admin_token) SSA_EMAIL = account_data["email"] SERVICE_ACCOUNT_ID = account_data["serviceAccountId"] key_data = create_service_account_key(admin_token, SERVICE_ACCOUNT_ID) KEY_ID = key_data["kid"] PRIVATE_KEY = key_data["privateKey"] print(f''' APS_CLIENT_ID="{APS_CLIENT_ID}" APS_SECRET_ID="{APS_SECRET_ID}" SERVICE_ACCOUNT_ID="{SERVICE_ACCOUNT_ID}" KEY_ID="{KEY_ID}" SSA_EMAIL="{SSA_EMAIL}" PRIVATE_KEY="{PRIVATE_KEY}"''') if __name__ == "__main__": main() ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Service Account Creation API Source: https://developer.doc.autodesk.com/bPlouYTd/cloud-platform-ssa-docs-main-460369/ssa/v1/tutorials/getting-started-with-ssa/about-this-walkthrough.html This section covers the API calls required to create a service account, including obtaining an admin token, creating the service account itself, and generating a key for it. ```APIDOC ## POST /token ### Description Obtains an admin access token using client credentials. ### Method POST ### Endpoint https://developer.api.autodesk.com/authentication/v2/token ### Parameters #### Query Parameters - **grant_type** (string) - Required - Specifies the grant type, which should be 'client_credentials' for this operation. - **scope** (string) - Required - A space-separated list of scopes to request. For admin operations, 'application:service_account:read', 'application:service_account:write', and 'application:service_account_key:write' are used. #### Request Body None ### Request Example ```python url = f"{BASE_URL}/token" data = { "grant_type": "client_credentials", "scope": " ".join(SCOPE_ADMIN) } response = requests.post(url, data=data, auth=(APS_CLIENT_ID, APS_SECRET_ID)) ``` ### Response #### Success Response (200) - **access_token** (string) - The obtained access token. #### Response Example ```json { "access_token": "your_access_token", "token_type": "Bearer", "expires_in": 3600 } ``` ## POST /service-accounts ### Description Creates a new service account with a specified name, first name, and last name. ### Method POST ### Endpoint https://developer.api.autodesk.com/authentication/v2/service-accounts ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **name** (string) - Required - The name of the service account. - **firstName** (string) - Required - The first name of the service account. - **lastName** (string) - Required - The last name of the service account. ### Request Example ```python url = f"{BASE_URL}/service-accounts" headers = {"Authorization": f"Bearer {admin_token}"} payload = { "name": f"{FIRST_NAME}-{LAST_NAME}", "firstName": FIRST_NAME, "lastName": LAST_NAME } response = requests.post(url, json=payload, headers=headers) ``` ### Response #### Success Response (200) - **email** (string) - The email address of the newly created service account. - **serviceAccountId** (string) - The unique identifier for the service account. #### Response Example ```json { "email": "service-mycompany-filesync@example.autodesk.com", "serviceAccountId": "some_service_account_id", "name": "service-mycompany-filesync", "firstName": "service", "lastName": "mycompany-filesync", "creationDate": "2023-10-27T10:00:00Z", "lastUpdatedDate": "2023-10-27T10:00:00Z" } ``` ## POST /service-accounts/{serviceAccountId}/keys ### Description Creates a new key for a specified service account. ### Method POST ### Endpoint https://developer.api.autodesk.com/authentication/v2/service-accounts/{serviceAccountId}/keys ### Parameters #### Path Parameters - **serviceAccountId** (string) - Required - The ID of the service account for which to create a key. #### Query Parameters None #### Request Body None ### Request Example ```python url = f"{BASE_URL}/service-accounts/{service_account_id}/keys" headers = {"Authorization": f"Bearer {admin_token}"} response = requests.post(url, headers=headers) ``` ### Response #### Success Response (200) - **kid** (string) - The key ID (Key Identifier). - **privateKey** (string) - The private key generated for the service account. #### Response Example ```json { "kid": "some_key_id", "privateKey": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----", "creationDate": "2023-10-27T10:05:00Z" } ``` ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### GET /construction/issues/v1/projects/{projectId}/issue-root-cause-categories Source: https://context7_llms Retrieves a list of supported root cause categories and root causes that you can allocate to an issue. For example, communication and coordination. ```APIDOC ## GET /construction/issues/v1/projects/{projectId}/issue-root-cause-categories ### Description Retrieves a list of supported root cause categories and root causes that you can allocate to an issue. For example, communication and coordination. ### Method GET ### Endpoint /construction/issues/v1/projects/{projectId}/issue-root-cause-categories ### Parameters #### Path Parameters - **projectId** (string) - Required - The ID of the project. #### Query Parameters - **include** (string) - Optional - Add ‘include=rootcauses’ to add the root causes for each category. - **limit** (integer) - Optional - Add limit=20 to limit the results count (together with the offset to support pagination). - **offset** (integer) - Optional - Add offset=20 to get partial results (together with the limit to support pagination). - **filter[updatedAt]** (string) - Optional - Retrieves root cause categories updated at the specified date and time, in one of the following URL-encoded formats: YYYY-MM-DDThh:mm:ss.sz or YYYY-MM-DD. Separate multiple values with commas. ### Response #### Success Response (200) - **id** (string) - The ID of the root cause category. - **name** (string) - The name of the root cause category. - **rootCauses** (array) - An array of root causes associated with the category (if `include=rootcauses` is used). - **id** (string) - The ID of the root cause. - **name** (string) - The name of the root cause. #### Response Example ```json { "data": [ { "id": "category-1", "name": "Communication", "rootCauses": [ { "id": "rootcause-1a", "name": "Lack of communication" }, { "id": "rootcause-1b", "name": "Miscommunication" } ] } ], "limit": 20, "offset": 0 } ``` ``` -------------------------------- ### Untitled No description -------------------------------- ### C# Get Access Token using JWT Assertion for Autodesk API Source: https://developer.doc.autodesk.com/bPlouYTd/cloud-platform-ssa-docs-main-460369/ssa/v1/tutorials/getting-started-with-ssa/about-this-walkthrough.html Obtains an access token from the Autodesk Developer API using a previously generated JWT assertion. This method makes an HTTP POST request to the token endpoint, including the JWT assertion and client credentials for Basic Authentication. It requires `System.Net.Http` and `System.Text` namespaces. ```csharp using System; using System.Collections.Generic; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; namespace Autodesk.Authentication { public static class AuthHelper { static async Task GetAccessToken(string jwtAssertion, string clientId, string clientSecret, string[] scope) { using HttpClient client = new HttpClient(); var request = new HttpRequestMessage(HttpMethod.Post, "https://developer.api.autodesk.com/authentication/v2/token"); request.Headers.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); request.Content = new FormUrlEncodedContent(new Dictionary { { "grant_type", "urn:ietf:params:oauth:grant-type:jwt-bearer" }, { "assertion", jwtAssertion }, { "scope", string.Join(" ", scope) } }); // Encode client ID and secret for basic auth var authenticationString = $"{clientId}:{clientSecret}"; var base64EncodedAuthenticationString = Convert.ToBase64String(Encoding.ASCII.GetBytes(authenticationString)); request.Headers.Authorization = new AuthenticationHeaderValue("Basic", base64EncodedAuthenticationString); var response = await client.SendAsync(request); response.EnsureSuccessStatusCode(); return await response.Content.ReadAsStringAsync(); } } } ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### POST /authentication/v2/token - Obtain Access Token Source: https://developer.doc.autodesk.com/bPlouYTd/cloud-platform-ssa-docs-main-460369/ssa/v1/tutorials/getting-started-with-ssa/about-this-walkthrough.html This endpoint is used to obtain an access token by providing a JWT assertion. The JWT assertion is generated using your client ID, private key, and requested scopes. ```APIDOC ## POST /authentication/v2/token ### Description This endpoint is used to obtain an access token from the Autodesk Forge API. It requires a JWT (JSON Web Token) assertion as proof of authorization, which is generated using your client credentials and the specific scopes you need access to. ### Method POST ### Endpoint https://developer.api.autodesk.com/authentication/v2/token ### Parameters #### Query Parameters - **grant_type** (string) - Required - Must be set to "urn:ietf:params:oauth:grant-type:jwt-bearer". - **assertion** (string) - Required - The JWT assertion generated from your client credentials and scopes. - **scope** (string) - Required - A space-delimited list of scopes for which the access token is requested. #### Request Body This endpoint uses `application/x-www-form-urlencoded` for the request body. - **grant_type** (string) - Required - The grant type, which must be `urn:ietf:params:oauth:grant-type:jwt-bearer`. - **assertion** (string) - Required - The JWT assertion. - **scope** (string) - Required - The requested scopes, space-delimited. ### Request Example ``` POST /authentication/v2/token HTTP/1.1 Host: developer.api.autodesk.com Content-Type: application/x-www-form-urlencoded Authorization: Basic grant_type=urn%3Aietf%3Aparams%3Aoauth%3Agrant-type%3Ajwt-bearer&assertion=&scope= ``` ### Response #### Success Response (200 OK) - **access_token** (string) - The obtained access token. - **token_type** (string) - The type of the token (e.g., "Bearer"). - **expires_in** (integer) - The lifetime of the token in seconds. #### Response Example ```json { "access_token": "Atza|IQEBL-u1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHijklmnopqrstuvwxyz01234567890abcd-1234567890abcdefghijklm", "token_type": "Bearer", "expires_in": 3600 } ``` ``` -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description -------------------------------- ### Untitled No description