Install & Compatibility
Where this runs
tested against v2.0.7 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.384s · 21.8MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 2.4s · import 0.368s · 22MB
20MB installed
● package 20MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
EdgeGridAuth
✓ from akamai.edgegrid import EdgeGridAuth
EdgeGridAuthHeaders
✓ from akamai.edgegrid import EdgeGridAuthHeaders
✗ from akamai.edgegrid.auth import EdgeGridAuthHeaders
The `EdgeGridAuthHeaders` class is directly importable from the top-level `akamai.edgegrid` package since v1.0.0.
This quickstart demonstrates how to authenticate `requests` sessions using `EdgeGridAuth` with credentials typically loaded from environment variables or an `.edgerc` file. It constructs a `requests.Session` object, applies the `EdgeGridAuth` instance, and then makes an example GET request to an Akamai API endpoint, handling potential errors.
import requests
import os
from akamai.edgegrid import EdgeGridAuth
# For simplicity, using environment variables.
# In production, use a .edgerc file (e.g., ~/.edgerc) and specify a section.
# Example .edgerc section:
# [default]
# host = your_api_host.akadns.net
# client_token = YOUR_CLIENT_TOKEN
# client_secret = YOUR_CLIENT_SECRET
# access_token = YOUR_ACCESS_TOKEN
# Configure from environment variables (less secure for production)
client_token = os.environ.get('AKAMAI_CLIENT_TOKEN', 'YOUR_CLIENT_TOKEN_HERE')
client_secret = os.environ.get('AKAMAI_CLIENT_SECRET', 'YOUR_CLIENT_SECRET_HERE')
access_token = os.environ.get('AKAMAI_ACCESS_TOKEN', 'YOUR_ACCESS_TOKEN_HERE')
host = os.environ.get('AKAMAI_HOST', 'https://your-api-host.akadns.net')
if client_token == 'YOUR_CLIENT_TOKEN_HERE' or \
client_secret == 'YOUR_CLIENT_SECRET_HERE' or \
access_token == 'YOUR_ACCESS_TOKEN_HERE' or \
host == 'https://your-api-host.akadns.net':
print("Warning: Please set AKAMAI_CLIENT_TOKEN, AKAMAI_CLIENT_SECRET, AKAMAI_ACCESS_TOKEN, and AKAMAI_HOST environment variables or update the example with actual credentials.")
print("Or configure a .edgerc file and initialize EdgeGridAuth with 'client_token=None' and 'section='your_section_name'")
else:
# Initialize EdgeGridAuth with credentials (from env vars in this case)
# For .edgerc file, use: auth = EdgeGridAuth(client_token=None, section='default')
auth = EdgeGridAuth(
client_token=client_token,
client_secret=client_secret,
access_token=access_token,
base_url=host
)
# Create a requests session and apply EdgeGridAuth
session = requests.Session()
session.auth = auth
# Example API call (replace with an actual Akamai API endpoint)
try:
response = session.get(f'{host}/diagnostic-tools/v2/locations') # Example path
response.raise_for_status() # Raise an exception for HTTP errors
print(f"Successfully authenticated and fetched data: {response.status_code}")
# print(response.json()) # Uncomment to see the response body
except requests.exceptions.HTTPError as e:
print(f"HTTP Error: {e} - {e.response.text}")
except requests.exceptions.RequestException as e:
print(f"Request Error: {e}")
Errors
Common errors & fixes
configparser.NoSectionError: No section: 'default'
This error occurs when the `edgegrid-python` library cannot find the specified section (often 'default') in your `.edgerc` credentials file, or the file itself is not found or is unreadable.
fixEnsure your `.edgerc` file exists in the expected location (e.g., `~/.edgerc`), is properly formatted with a `[default]` section containing your credentials, and is readable by the Python process. If using a custom path, explicitly provide it when initializing `EdgeRc` (e.g., `EdgeRc('/path/to/your/.edgerc')`). Invalid Signature
This error, often appearing as 'The signature does not match' in the API response, indicates that the cryptographic signature generated by `edgegrid-python` for your request does not match the signature expected by the Akamai API. Common causes include incorrect API credentials (client token, client secret, access token, host), issues with the request body size exceeding limits for signing, or malformed requests.
fixVerify that all API credentials in your `.edgerc` file or hardcoded in your script are correct and match what Akamai provided. For requests with a body, be aware of the `max_body` configuration setting; if your body size exceeds this, only a portion is signed. Ensure multi-part form data is handled correctly as it can also lead to signature mismatches.
ModuleNotFoundError: No module named 'akamai.edgegrid'
This Python error means the `edgegrid-python` library or its `akamai.edgegrid` package was not found by your Python interpreter. This typically happens if the library was not installed, was installed into a different Python environment, or there are path issues.
fixInstall the library using pip: `pip install edgegrid-python`. If you have multiple Python versions, use `pip3 install edgegrid-python` to ensure it installs for Python 3. Always work within a virtual environment to manage dependencies.
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 1: ordinal not in range(128)
This error, often seen during installation or when using related tools like `httpie-edgegrid`, indicates an incompatibility with Python 2, which is no longer supported by `edgegrid-python` and its ecosystem. The error arises from Python 2's default ASCII handling attempting to decode non-ASCII bytes.
fixEnsure you are using Python 3.10 or later. If encountering this during installation, explicitly use `pip3` to install the package: `pip3 install edgegrid-python` or `pip3 install httpie-edgegrid`.
Upgrade
Version history
2.0.7latest on PyPI · released May 19, 2026
Audit
Dependencies
requestsrequiredWhile decoupled as a direct dependency in v1.3.0+, this library's primary use case is to provide authentication for `requests.Session` objects.