### Install urllib3-sigv4 with pip Source: https://github.com/tlinhart/urllib3-sigv4/blob/main/README.md Use pip to install the package. This is the standard method for installing Python packages. ```bash pip install urllib3_sigv4 ``` -------------------------------- ### Install urllib3-sigv4 with uv Source: https://github.com/tlinhart/urllib3-sigv4/blob/main/README.md Use uv, a fast Python package installer, to add the package to your project. ```bash uv add urllib3_sigv4 ``` -------------------------------- ### Create a SigV4RequestSigner instance Source: https://github.com/tlinhart/urllib3-sigv4/blob/main/README.md Instantiate SigV4RequestSigner with the AWS service name. Optional parameters like region, access_key, and secret_key can be provided or will be inferred from the environment via Boto3. ```python from urllib3_sigv4 import SigV4RequestSigner signer = SigV4RequestSigner( "lambda", region="eu-central-1", access_key="AKIAIOSFODNN7EXAMPLE", secret_key="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" ) ``` -------------------------------- ### Make signed requests using top-level request function Source: https://github.com/tlinhart/urllib3-sigv4/blob/main/README.md Utilize the convenience top-level request function, which uses a module-global PoolManager instance, to make signed requests by passing a SigV4RequestSigner. ```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()) ``` -------------------------------- ### Make signed requests using PoolManager Source: https://github.com/tlinhart/urllib3-sigv4/blob/main/README.md Create a PoolManager instance with a SigV4RequestSigner to automatically sign requests. This is useful for making repeated signed requests to an AWS service. ```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()) ``` -------------------------------- ### Override default signer in request method Source: https://github.com/tlinhart/urllib3-sigv4/blob/main/README.md Provide a SigV4RequestSigner instance directly to the http.request method to sign specific requests, overriding any default signer configured in the PoolManager. ```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()) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.