AWS signature version 4 signing process for the python requests module
84
Build a library that authenticates HTTP requests to AWS services using AWS Signature Version 4.
Your library should provide functionality to sign HTTP requests using AWS credentials (access key ID and secret access key) following the AWS Signature Version 4 signing process. The authenticator should integrate with the Python requests library and add the necessary authentication headers to outgoing requests.
The authenticator should:
requests library as an authentication handler@generates
class AWSRequestAuth:
"""
Authenticates HTTP requests using AWS Signature Version 4.
This class integrates with the requests library to automatically
sign HTTP requests with AWS credentials.
"""
def __init__(self, aws_access_key, aws_secret_access_key, aws_host,
aws_region, aws_service, aws_token=None):
"""
Initialize the AWS request authenticator.
Args:
aws_access_key: AWS access key ID
aws_secret_access_key: AWS secret access key
aws_host: AWS service host (e.g., 'es.us-east-1.amazonaws.com')
aws_region: AWS region (e.g., 'us-east-1')
aws_service: AWS service name (e.g., 'es', 'execute-api')
aws_token: Optional session token for temporary credentials
"""
pass
def __call__(self, request):
"""
Sign the request and add authentication headers.
This method is called by the requests library when this
authenticator is used as the auth parameter.
Args:
request: A requests PreparedRequest object
Returns:
The modified request with authentication headers added
"""
passProvides AWS Signature Version 4 signing functionality for HTTP requests.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/pypi-aws-requests-authdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10