urllib3-sigv4


Nameurllib3-sigv4 JSON
Version 1.1.0 PyPI version JSON
download
home_pageNone
SummaryExtension to urllib3 adding support for AWS Signature Version 4
upload_time2025-07-15 19:19:21
maintainerNone
docs_urlNone
authorNone
requires_python>=3.9
licenseNone
keywords aws sigv4 urllib
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # urllib3 SigV4

Extension to [urllib3](https://github.com/urllib3/urllib3) adding support for
signing the requests with AWS Signature Version 4. It uses the
[Boto3](https://github.com/boto/boto3) library for handling the AWS credentials
and the actual signing process.

## Installation

To install the package, use either `pip`:

```bash
pip install urllib3_sigv4
```

or `uv`:

```bash
uv add urllib3_sigv4
```

## Usage

This library provides a drop-in replacement for two main components of urllib3,
the [`PoolManager`](https://urllib3.readthedocs.io/en/stable/reference/urllib3.poolmanager.html)
class and the top-level [`request`](https://urllib3.readthedocs.io/en/stable/reference/urllib3.request.html)
method. It adds a new optional parameter which determines if and how the
requests should be signed.

### Creating a Signer

First, create an instance of the `SigV4RequestSigner` class which defines the
parameters for request signing:

```python
from urllib3_sigv4 import SigV4RequestSigner

signer = SigV4RequestSigner(
    "lambda",
    region="eu-central-1",
    access_key="AKIAIOSFODNN7EXAMPLE",
    secret_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
)
```

The first parameter is mandatory and identifies the AWS service we want to make
requests to (AWS Lambda in this case). The `region`, `access_key` and
`secret_key` parameters are optional and will be inferred from the environment
if not passed (via the default Boto3 session, see
[here](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/session.html)
and [here](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html)
for more details).

### Making Requests

To make signed requests to an AWS service, pass the signer instance via the
`signer` parameter when creating the `PoolManager`:

```python
from urllib3_sigv4 import PoolManager, SigV4RequestSigner

signer = SigV4RequestSigner("lambda")
http = PoolManager(signer=signer)

response = http.request(
    "POST",
    "https://my-lambda-url-id.lambda-url.eu-central-1.on.aws",
    json={"name": "John Doe", "age": 30}
)
print(response.json())
```

You can also provide the signer in individual `request` method calls to
override the default behavior:

```python
from urllib3_sigv4 import PoolManager, SigV4RequestSigner

signer = SigV4RequestSigner("lambda")
http = PoolManager()

# The same as when using urllib3's PoolManager.
response = http.request("GET", "https://httpbin.org/get")
print(response.json())

# This request will be signed.
response = http.request(
    "POST",
    "https://my-lambda-url-id.lambda-url.eu-central-1.on.aws",
    json={"name": "John Doe", "age": 30},
    signer=signer
)
print(response.json())
```

You can also use a convenience top-level `request` method which uses a
module-global `PoolManager` instance:

```python
from urllib3_sigv4 import SigV4RequestSigner, request

signer = SigV4RequestSigner("lambda")

response = request(
    "POST",
    "https://my-lambda-url-id.lambda-url.eu-central-1.on.aws",
    json={"name": "John Doe", "age": 30},
    signer=signer
)
print(response.json())
```

## Reference

- https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-signing.html
- https://github.com/aws-samples/sigv4-signing-examples
- https://github.com/awslabs/aws-sdk-python-signers

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "urllib3-sigv4",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "aws, sigv4, urllib",
    "author": null,
    "author_email": "Tom\u00e1\u0161 Linhart <pasmen@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/04/09/8b17948c7fa8c2ae18ec6fc168c7dced5dc95ebb8ef6af03b301c057a48d/urllib3_sigv4-1.1.0.tar.gz",
    "platform": null,
    "description": "# urllib3 SigV4\n\nExtension to [urllib3](https://github.com/urllib3/urllib3) adding support for\nsigning the requests with AWS Signature Version 4. It uses the\n[Boto3](https://github.com/boto/boto3) library for handling the AWS credentials\nand the actual signing process.\n\n## Installation\n\nTo install the package, use either `pip`:\n\n```bash\npip install urllib3_sigv4\n```\n\nor `uv`:\n\n```bash\nuv add urllib3_sigv4\n```\n\n## Usage\n\nThis library provides a drop-in replacement for two main components of urllib3,\nthe [`PoolManager`](https://urllib3.readthedocs.io/en/stable/reference/urllib3.poolmanager.html)\nclass and the top-level [`request`](https://urllib3.readthedocs.io/en/stable/reference/urllib3.request.html)\nmethod. It adds a new optional parameter which determines if and how the\nrequests should be signed.\n\n### Creating a Signer\n\nFirst, create an instance of the `SigV4RequestSigner` class which defines the\nparameters for request signing:\n\n```python\nfrom urllib3_sigv4 import SigV4RequestSigner\n\nsigner = SigV4RequestSigner(\n    \"lambda\",\n    region=\"eu-central-1\",\n    access_key=\"AKIAIOSFODNN7EXAMPLE\",\n    secret_key=\"wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY\"\n)\n```\n\nThe first parameter is mandatory and identifies the AWS service we want to make\nrequests to (AWS Lambda in this case). The `region`, `access_key` and\n`secret_key` parameters are optional and will be inferred from the environment\nif not passed (via the default Boto3 session, see\n[here](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/session.html)\nand [here](https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html)\nfor more details).\n\n### Making Requests\n\nTo make signed requests to an AWS service, pass the signer instance via the\n`signer` parameter when creating the `PoolManager`:\n\n```python\nfrom urllib3_sigv4 import PoolManager, SigV4RequestSigner\n\nsigner = SigV4RequestSigner(\"lambda\")\nhttp = PoolManager(signer=signer)\n\nresponse = http.request(\n    \"POST\",\n    \"https://my-lambda-url-id.lambda-url.eu-central-1.on.aws\",\n    json={\"name\": \"John Doe\", \"age\": 30}\n)\nprint(response.json())\n```\n\nYou can also provide the signer in individual `request` method calls to\noverride the default behavior:\n\n```python\nfrom urllib3_sigv4 import PoolManager, SigV4RequestSigner\n\nsigner = SigV4RequestSigner(\"lambda\")\nhttp = PoolManager()\n\n# The same as when using urllib3's PoolManager.\nresponse = http.request(\"GET\", \"https://httpbin.org/get\")\nprint(response.json())\n\n# This request will be signed.\nresponse = http.request(\n    \"POST\",\n    \"https://my-lambda-url-id.lambda-url.eu-central-1.on.aws\",\n    json={\"name\": \"John Doe\", \"age\": 30},\n    signer=signer\n)\nprint(response.json())\n```\n\nYou can also use a convenience top-level `request` method which uses a\nmodule-global `PoolManager` instance:\n\n```python\nfrom urllib3_sigv4 import SigV4RequestSigner, request\n\nsigner = SigV4RequestSigner(\"lambda\")\n\nresponse = request(\n    \"POST\",\n    \"https://my-lambda-url-id.lambda-url.eu-central-1.on.aws\",\n    json={\"name\": \"John Doe\", \"age\": 30},\n    signer=signer\n)\nprint(response.json())\n```\n\n## Reference\n\n- https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-signing.html\n- https://github.com/aws-samples/sigv4-signing-examples\n- https://github.com/awslabs/aws-sdk-python-signers\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Extension to urllib3 adding support for AWS Signature Version 4",
    "version": "1.1.0",
    "project_urls": {
        "Homepage": "https://github.com/tlinhart/urllib3-sigv4"
    },
    "split_keywords": [
        "aws",
        " sigv4",
        " urllib"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "fa772607259ef85d46a1fdda8cbd6318d7452fe693db2b7999506873ad5d1666",
                "md5": "f3f13b0b68aaf7731e97bbc15697a309",
                "sha256": "15fbfe56139281f89e6eee1a2908a67271ce1de5afb7eb26d6ad543c9aaa9029"
            },
            "downloads": -1,
            "filename": "urllib3_sigv4-1.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f3f13b0b68aaf7731e97bbc15697a309",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 4897,
            "upload_time": "2025-07-15T19:19:20",
            "upload_time_iso_8601": "2025-07-15T19:19:20.347365Z",
            "url": "https://files.pythonhosted.org/packages/fa/77/2607259ef85d46a1fdda8cbd6318d7452fe693db2b7999506873ad5d1666/urllib3_sigv4-1.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "04098b17948c7fa8c2ae18ec6fc168c7dced5dc95ebb8ef6af03b301c057a48d",
                "md5": "df1f6a89b42a309a9b8f3cb36b678534",
                "sha256": "f2b3fbc9cbf3257004ae3b8396bd88b6cf488c42990ffe71050825af063b6191"
            },
            "downloads": -1,
            "filename": "urllib3_sigv4-1.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "df1f6a89b42a309a9b8f3cb36b678534",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 6463,
            "upload_time": "2025-07-15T19:19:21",
            "upload_time_iso_8601": "2025-07-15T19:19:21.606594Z",
            "url": "https://files.pythonhosted.org/packages/04/09/8b17948c7fa8c2ae18ec6fc168c7dced5dc95ebb8ef6af03b301c057a48d/urllib3_sigv4-1.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-07-15 19:19:21",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "tlinhart",
    "github_project": "urllib3-sigv4",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "urllib3-sigv4"
}
        
Elapsed time: 0.91067s