Company Authentication
Learn how to get your Company TNID client key and secret to authenticate into the GraphQL API.
Last updated
{
"client_id": CLIENT_ID_VALUE,
"client_secret": CLIENT_SECRET_VALUE
}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)