requests-sigv4 is a Python library designed to provide AWS Signature Version 4 (SigV4) authentication for the popular `requests` library. It enables users to make signed requests to AWS API endpoints, which is crucial for interacting with many AWS services. The library is currently at version 0.1.6 and was last updated in June 2022. Due to the lack of available documentation or an active source repository, its exact release cadence is unknown, but it appears to be a stable utility.
pip install requests-sigv4Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up `requests-sigv4` to sign an HTTP GET request to an AWS API Gateway endpoint. It assumes AWS credentials are available via environment variables or explicitly passed. The specific constructor signature for `SigV4Auth` is inferred based on common patterns in similar libraries due to a lack of direct documentation for this package. Users should adapt the `SERVICE`, `REGION`, and `API_ENDPOINT` to their specific AWS setup. Authentication details like `aws_access_key_id`, `aws_secret_access_key`, and `aws_session_token` are retrieved from environment variables for security and flexibility. The example uses a `requests.Session` for persistent configuration.
Refer to the source code if it becomes available, or consider using alternative, well-documented SigV4 libraries for 'requests' (e.g., `requests-aws4auth`, `requests-iamauth`, `aws-requests-auth`) for production environments. Thorough testing with this specific library is essential.
Ensure all required headers (e.g., `Host`, `x-amz-date`) are correctly set. For POST requests, ensure `x-amz-content-sha256` header is included, especially if the body is empty or a hash of the empty string. Debugging AWS SigV4 often involves comparing the canonical request and string-to-sign with AWS documentation or sample implementations.
Verify that your AWS credentials are correct and not expired. Ensure the IAM user or role associated with the credentials has the necessary policies attached (e.g., `execute-api:Invoke` for API Gateway). When using temporary credentials, make sure `AWS_SESSION_TOKEN` is also provided if applicable.