Receipt of Waste - API Authentication Guide
To use the Receipt API, you must first obtain an OAuth access token.
After completing the registration process, you will receive the following credentials from the Digital Waste Tracking service team:
- Client ID
- Client Secret
These credentials are used to request an access token from the OAuth service.
Authentication process
This process involves two steps:
- Use your Client ID and Client Secret to request an access token.
- Include the access token in API requests using the Bearer authentication scheme.
Authentication sequence diagram
Step 1: Request an access token
Send a POST request to the OAuth service.
import requests #use requests library
import base64
def get_cognito_token(client_id, client_secret, token_url): # your clientID, Client Secret and OAuth URL
client_credentials = f"{client_id}:{client_secret}"
encoded_credentials = base64.b64encode(client_credentials.encode()).decode()
headers = { "Authorization": f"Basic {encoded_credentials}", "Content-Type": "application/x-www-form-urlencoded" }
payload = { "grant_type": "client_credentials", "client_id": client_id, "client_secret": client_secret, }
response = requests.post(f"{token_url}/oauth2/token", headers=headers, data=payload)
response.raise_for_status()
token_response = response.json()
return token_response["access_token"]
cURL example
curl --request POST \
--url "https://YOUR-OAUTH-URL/oauth2/token" \
--user "$CLIENTID:$CLIENTSECRET" \
--header "Content-Type: application/x-www-form-urlencoded" \
--data "grant_type=client_credentials"
Successful response
{
"access_token": "eyJraWQiOiJ...",
"expires_in": 3600,
"token_type": "Bearer"
}
The expires_in value indicates how long the access token remains valid, in seconds. In the example above, the access token remains valid for 3,600 seconds (60 minutes). Applications should continue using the same access token until it expires.
Reuse your access token
Request an access token once, then reuse it for every API request until it’s about to expire. Do not request a new token for each API request. A successful response includes expires_in, which tells you how many seconds the token is valid for.
Client ID + Client Secret
↓
Access Token
↓
API Request 1
↓
API Request 2
↓
API Request 3
↓
Token Expires
↓
Request New Token
Get a new token when:
- The token is close to expiring
- An API request returns a 401 Unauthorized response
Reusing your token means fewer requests, because you’re not sending an extra request to the token service each time. It also stops your software being throttled, because the token service may limit how many token requests it accepts.
Step 2: Call the Receipt API
Include the access token in the Authorization header.
import requests
def make_api_request(access_token, api_url): # your access token and the api url here
headers = { "Authorization": f"Bearer {access_token}" }
response = requests.get(api_url, headers=headers)
response.raise_for_status()
return response.json()
What is the OAuth login URL for my API?
Production: https://waste-movement-external-api-75ee2.auth.eu-west-2.amazoncognito.com
Test: https://waste-movement-external-api-8ec5c.auth.eu-west-2.amazoncognito.com
Testing your credentials
You can verify your credentials are valid using the following cURL and Python scripts. If the scripts return an error, your credentials were entered incorrectly. If the scripts return an access token then your credentials are correct.
Two cURL and Python example scripts are provided, one each for the production and test environments.
In the cURL scripts replace $CLIENTID with your client ID and replace $CLIENTSECRET with your client secret.
In the Python scripts under Test credentials, replace "YOUR_CLIENT_ID" with your client ID and replace "YOUR_CLIENT_SECRET" with your client secret.
Production Environment
curl --request POST \
--url https://waste-movement-external-api-75ee2.auth.eu-west-2.amazoncognito.com/oauth2/token \
--user "$CLIENTID:$CLIENTSECRET" \
--header "Content-Type: application/x-www-form-urlencoded" \
--data "grant_type=client_credentials"
Test Environment
curl --request POST \
--url https://waste-movement-external-api-8ec5c.auth.eu-west-2.amazoncognito.com/oauth2/token \
--user "$CLIENTID:$CLIENTSECRET" \
--header "Content-Type: application/x-www-form-urlencoded" \
--data "grant_type=client_credentials"
Python Examples
Production Environment
import requests
def get_access_token(client_id, client_secret):
response = requests.post("https://waste-movement-external-api-75ee2.auth.eu-west-2.amazoncognito.com/oauth2/token",
auth=(client_id, client_secret),
data={
"grant_type": "client_credentials"
}
)
response.raise_for_status()
return response.json()["access_token"]
# Prod credentials
client_id = "YOUR_CLIENT_ID"
client_secret = "YOUR_CLIENT_SECRET"
try:
access_token = get_access_token(client_id, client_secret)
print("Authentication successful")
print("Access Token:")
print(access_token)
except requests.exceptions.HTTPError as e:
print(f"Authentication failed: {e}")
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
Test Environment
import requests
def get_access_token(client_id, client_secret):
response = requests.post("https://waste-movement-external-api-8ec5c.auth.eu-west-2.amazoncognito.com/oauth2/token",
auth=(client_id, client_secret),
data={
"grant_type": "client_credentials"
}
)
response.raise_for_status()
return response.json()["access_token"]
# Test credentials
client_id = "YOUR_CLIENT_ID"
client_secret = "YOUR_CLIENT_SECRET"
try:
access_token = get_access_token(client_id, client_secret)
print("Authentication successful")
print("Access Token:")
print(access_token)
except requests.exceptions.HTTPError as e:
print(f"Authentication failed: {e}")
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
Page last updated on December 1st 2026.