AWS Request Signer
raw JSON → 1.2.0 verified Mon Apr 27 auth: no python
A Python library to sign AWS requests using AWS Signature V4. Current version is 1.2.0, with a stable release cadence. Supports Python 3.6+ and aims to simplify request signing for AWS services.
pip install aws-request-signer Common errors
error AttributeError: module 'aws_request_signer' has no attribute 'AWSRequestSigner' ↓
cause Incorrect import path or capitalization; the class is AWSRequestSigner (note capital letters).
fix
Use: from aws_request_signer import AWSRequestSigner
error TypeError: sign() missing 1 required positional argument: 'body' ↓
cause The sign method requires exactly four positional arguments (method, url, headers, body).
fix
Provide all four arguments, including an empty string for body if no request body.
Warnings
gotcha The signer does NOT verify endpoint URLs or credentials at initialization; invalid params only fail at signing time. ↓
fix Ensure credentials and region are correct before calling sign() to avoid opaque errors.
deprecated The library does not support AWS Signature V4A or temporary credentials from STS automatically; you must supply temp creds manually. ↓
fix If using temporary credentials (session token), include it as a custom header or use a different library that supports session tokens natively.
Imports
- AWSRequestSigner wrong
from aws_request_signer import aws_request_signercorrectfrom aws_request_signer import AWSRequestSigner
Quickstart
import os
from aws_request_signer import AWSRequestSigner
# Set your credentials via environment variables
access_key = os.environ.get('AWS_ACCESS_KEY_ID', '')
secret_key = os.environ.get('AWS_SECRET_ACCESS_KEY', '')
region = 'us-east-1'
service = 'execute-api'
signer = AWSRequestSigner(access_key, secret_key, region, service)
# Example GET request
method = 'GET'
url = 'https://example.com/dev'
headers = {}
body = ''
signed_headers = signer.sign(method, url, headers, body)
print(signed_headers)