Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

requests-iamauth

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

requests-iamauth

AWS IAM Authorizer.

  • 0.8.0
  • PyPI
  • Socket score

Maintainers
1

Requests IAMAuth

pypi python pytest coverage maintainability

Use AWS SigV4 authorization with requests.

Accessing an API secured with IAM authorization in AWS API Gateway can be tricky.

This tool uses the built-in authorization strategy in requests to help you access your secured endpoints.

Installation

pip install requests-iamauth

Usage

Signing Version 4

AWS sigv4 is the current standard for signing requests bound for AWS services.

Use requests-iamauth to as an authorizer for the requests Python library:

import requests
from iamauth import Sigv4Auth

sigv4 = Sigv4Auth(
  service_name="execute-api",  # default
)

session = requests.Session()
session.auth = sigv4
session.get('https://abcdef0123.execute-api.us-east-2.amazonaws.com/my/api')

Override the default boto3 session by passing a custom one into the constructor for Sigv4Auth:

import boto3

sigv4 = Sigv4Auth(
  boto3_session=boto3.Session(),
)

Signing Version 4a

AWS sigv4a is an extension to the sigv4 signing process that enables signing requests bound for more than one region.

Note — at the time of this writing, the only API Gateway API type that appears to support the new sigv4a are REST APIs.

Use requests-iamauth to as an authorizer for the requests Python library:

import requests
from iamauth import Sigv4aAuth

sigv4a = Sigv4aAuth(
  service="execute-api",  # default
  region="*",             # default
)

session = requests.Session()
session.auth = sigv4a
session.get('https://abcdef0123.execute-api.us-east-2.amazonaws.com/my/api')

Override the default AWS credentials provider by passing a custom one into the constructor for Sigv4aAuth:

from botocore.compat import awscrt

sigv4a = Sigv4aAuth(
  credentials_provider=awscrt.auth.AwsCredentialsProvider.new_default_chain(),
)

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc