# Copy this code and save it to a file called get-token.py
# Install dependencies with command: pip install requests pyperclip
# Run the script with command: python get-token.py
# User-Agent is set explicitly so default library agents (e.g. python-requests) are not rejected by the gateway.
import requests
import pyperclip
# Fill in your credentials below
CLIENT_ID = "REPLACE-ME-WITH-CLIENT-ID"
CLIENT_SECRET = "REPLACE-ME-WITH-CLIENT-SECRET"
SCOPE = "REPLACE-ME-WITH-SCOPE"
# Get access token
response = requests.post(
"https://id.talenom.com/api/b2b/oauth2/v1.0/token",
data="grant_type=client_credentials&client_id=" + CLIENT_ID + "&client_secret=" + CLIENT_SECRET + "&scope=" + SCOPE,
headers={"Content-Type": "application/x-www-form-urlencoded", "User-Agent": "Easor-API-Client/1.0"},
timeout=30,
)
if not response.ok:
print(f"Token request failed with HTTP {response.status_code}")
print(f"Content-Type: {response.headers.get('Content-Type', '')}")
print(response.text[:500])
response.raise_for_status()
access_token = response.json()["access_token"]
# Copy to clipboard
pyperclip.copy(access_token)
print("Access token:", access_token)
print("Access token also copied to your clipboard!")