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.

Send a request

Get your API access token

‌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. 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.

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")

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:

200 OK

{

"access_token": "string",

"expires_in": 36000,

...

}

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.

Errors

Please see Get and use an Authorization Token and Error codes for more details on types of errors, and how to resolve them.

Last updated