### Sample Paginated Response Structure Source: https://developer.primetric.com/ This is an example of a paginated response from a Primetric API endpoint. It includes the total count of items, URLs for the next and previous pages, and the array of results. ```json { "count": 99, "next": "https://api.primetric.com/beta/projects/?page=2" "previous": null, "results": [...] } ``` -------------------------------- ### Get Access Token (Client Credentials) Source: https://developer.primetric.com/ This snippet demonstrates how to obtain an access token using the client credentials grant type for API authentication. The token grants access based on the specified scopes. ```APIDOC ## Get Access Token (Client Credentials) ### Description This endpoint is used to obtain an OAuth 2.0 access token using the client credentials grant type. This token is required to authenticate subsequent API requests. The token's permissions are determined by the scopes requested. ### Method POST ### Endpoint https://api.primetric.com/auth/token/ ### Parameters #### Request Body - **grant_type** (string) - Required - Must be "client_credentials". - **scope** (string) - Required - A space-separated string of requested scopes (e.g., "read write finance"). ### Request Example ```python import requests from requests.auth import HTTPBasicAuth url = "https://api.primetric.com/auth/token/" client_id = "xx" client_secret = "yy" scope = ["read", "write", "finance"] auth = HTTPBasicAuth(client_id, client_secret) data = { "grant_type": "client_credentials", "scope": " ".join(scope) } response = requests.post(url, data=data, auth=auth) print(response.text) ``` ### Response #### Success Response (200 OK) - **access_token** (string) - The obtained access token. - **token_type** (string) - The type of the token, usually "Bearer". - **expires_in** (integer) - The token's lifetime in seconds. - **scope** (string) - The scopes granted for this token. #### Response Example ```json { "access_token": "", "token_type": "Bearer", "expires_in": 3600, "scope": "read write finance" } ``` ### Scopes - **read**: Grants read-only access to data. - **write**: Grants read and write access to data. - **finance**: Grants access to financial data. ``` -------------------------------- ### Get Access Token using Client Credentials Source: https://developer.primetric.com/ Use this Python snippet to obtain an access token from the Primetric API using the client credentials grant type. Ensure you have your client ID and client secret. ```python import requests from requests.auth import HTTPBasicAuth url = "https://api.primetric.com/auth/token/" client_id = "xx" client_secret = "yy" scope = ["read", "write", "finance"] auth = HTTPBasicAuth(client_id, client_secret) data = { "grant_type": "client_credentials", "scope": " ".join(scope) } response = requests.post(url, data=data, auth=auth) print(response.text) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.