# Get your access token

To follow this guide, you need a demo account. Make sure it's fully set up according to our instructions on how to [request a demo account](https://docs.certn.co/api/start/demo-account).

## Send a request <a href="#request" id="request"></a>

‌To communicate with our API, you'll need to build HTTP requests. You can use the programming language of your choice to achieve this. We provide examples of scripts using [Python](https://www.python.org/)![](https://1603615932-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mb7UCYXOrIqSvqbGTR2%2Fuploads%2Fbdlx8v4ady44WZ7x7y0K%2F16x16_2.png?alt=media\&token=63e63f36-8c7e-4f14-b435-1aabf76a9cdb), but most of the content you'll work with will be in [JSON](https://en.wikipedia.org/wiki/JSON)![](https://1603615932-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mb7UCYXOrIqSvqbGTR2%2Fuploads%2Fbdlx8v4ady44WZ7x7y0K%2F16x16_2.png?alt=media\&token=63e63f36-8c7e-4f14-b435-1aabf76a9cdb).‌

## Get your API access token <a href="#get-your-api-key" id="get-your-api-key"></a>

‌To gain access to our API, you will need your **Client ID** and **Client Secret**. Instructions for getting these values can be found in [use-the-api](https://docs.certn.co/api/guides/use-the-api "mention"). You should take special precautions to keep your client secret a secret. In the example below (using our demo environment `https://demo-api.certn.co`), we show you how you can use secrets stored in a `.env` file.

First, make a request to get your access token. This token will be required to make all other API requests. For this step, make a GET request to our `/token/` endpoint. If you're new to HTTP requests, visit [W3Schools](https://www.w3schools.com/tags/ref_httpmethods.asp)![](https://1603615932-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-Mb7UCYXOrIqSvqbGTR2%2Fuploads%2Fbdlx8v4ady44WZ7x7y0K%2F16x16_2.png?alt=media\&token=63e63f36-8c7e-4f14-b435-1aabf76a9cdb) for useful guides.

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

```python
import requests
from dotenv import dotenv_values


# An example of how to manage your Client ID and Client Secret, using a .env file
secrets = dotenv_values(".env")

client_id = secrets["CLIENT_ID"]
client_secret = secrets["CLIENT_SECRET"]

# add the 
headers = {
    "Content-Type": "application/x-www-form-urlencoded"
}
body = {"grant_type": "client_credentials"}

# url to retrieve your access token
url = "https://demo-api.certn.co/token/"

# Send the HTTP request to the API via POST, 
# including your Client ID and Client Secret for authentication
response = requests.post(
    url, 
    headers=headers, 
    auth=(client_id, client_secret), 
    data=body
)

# retrieve the access token
access_token = response.data.get("access_token")
```

{% endtab %}
{% endtabs %}

With everything set properly and a good internet connection, you should receive a `response.status_code` of `200 OK`. The `response.data` object should look something like:

{% hint style="success" %}
**200 OK**

`{`

&#x20;   `"access_token": "string",`

&#x20;   `"expires_in": 36000,`

&#x20;   `...`

`}`
{% endhint %}

You'll need this access\_token as a bearer token in headers for all requests to our API. Let's see how to use this to [understand-your-general-resources](https://docs.certn.co/api/start/demo-account/understand-your-general-resources "mention").

## Errors

Please see [authorization-header](https://docs.certn.co/api/guides/use-the-api/authorization-header "mention") and [error-codes](https://docs.certn.co/api/api-reference/resources/error-codes "mention") for more details on types of errors, and how to resolve them.
