> For the complete documentation index, see [llms.txt](https://docs.tnid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.tnid.com/authentication/company-authentication.md).

# Company Authentication

<figure><img src="/files/YZiO4uaG9Wz7TWMbw7Sw" alt=""><figcaption><p>Screenshot of Client Secrets section in GUI</p></figcaption></figure>

Company users of TNID are currently able to generate Client Secrets so that they can access the API. To create a Company, first register as an Individual, and then create a Company associated with your Individual profile. Then, assume the role of your Company and click "New Client Secret" in order to create your credentials.

{% hint style="danger" %}
You are only allowed to view your Client Secret value at creation, so please ensure you save it someplace safe (e.g. 1Password or your environment variables).  You will not be able to see it once you close the pop-up (however, you can always create a new Client Secret.
{% endhint %}

{% hint style="warning" %}
We do not expire tokens or force password resets at any time. We follow the latest NIST guidelines and believe in a strong, lengthy secure password protocol. Create new Client Secrets if you believe there is evidence of a compromise.
{% endhint %}

### Generate Your Bearer Token

The below URLs are available to create your API token, depending on your environment:

{% embed url="<https://api.staging.v2.tnid.com/auth/token>" %}
Staging Environment
{% endembed %}

{% embed url="<https://api.demo.v2.tnid.com/auth/token>" %}
Demo / Beta Environment
{% endembed %}

Simply pass the client\_id and client\_secret data to generate your Bearer token for future API requests:

```
{
   "client_id": CLIENT_ID_VALUE,
   "client_secret": CLIENT_SECRET_VALUE
}
```

Use the access\_token from the response to interact with the GraphQL api at /company.

### Example Company authentication using various languages

{% tabs %}
{% tab title="Python" %}

```python
import requests

def get_bearer_token(client_id, client_secret):
    url = "https://api.staging.v2.tnid.com/auth/token"
    
    # Define the headers and body of the request
    headers = {
        "Content-Type": "application/x-www-form-urlencoded"
    }
    
    # The payload or data to be sent in the POST request
    data = {
        "client_id": client_id,
        "client_secret": client_secret
    }
    
    # Make the POST request to the token endpoint
    response = requests.post(url, headers=headers, data=data)
    
    # Check if the request was successful
    if response.status_code == 200:
        # Parse the response and extract the access token
        token_data = response.json()
        return token_data.get("access_token")
    else:
        raise Exception(f"Failed to retrieve token: {response.status_code} {response.text}")

# Example usage:
client_id = "your_client_id"      # Replace with your actual client ID
client_secret = "your_client_secret"  # Replace with your actual client secret

token = get_bearer_token(client_id, client_secret)
print("Bearer Token:", token)
```

{% endtab %}

{% tab title="Coming Soon" %}

{% endtab %}
{% endtabs %}
