Skip to main content

session-adapters

PyPI - Version PyPI - Python Version GitHub Actions Workflow Status Code coverage

Requests transport adapters for bearer-authenticated http(s)://, file://, s3://, and oci:// URLs.

Read the documentation

Why This Project

session-adapters lets you use a standard requests.Session with authenticated HTTP requests and non-HTTP backends:

  • http:// and https:// with bearer token authentication
  • file:// for local filesystem artifacts
  • s3:// for AWS S3 objects and prefix listings
  • oci:// for OCI registry artifacts (via ORAS client)

This keeps one client interface while changing only the URL scheme.

Installation

pip install session-adapters

Quick Start

import requests

from session_adapters.bearer_auth_http_adapter import BearerAuthHTTPAdapter
from session_adapters.file_adapter import FileAdapter
from session_adapters.oci_adapter import OCIAdapter
from session_adapters.s3_adapter import S3Adapter

session = requests.Session()
session.mount("https://", BearerAuthHTTPAdapter("my-token"))
session.mount("file://", FileAdapter())
session.mount("s3://", S3Adapter())
session.mount("oci://", OCIAdapter())

# Bearer-authenticated HTTPS request
resp = session.get("https://api.example.com/resource")
print(resp.status_code)

# Local file
resp = session.get("file:///tmp/example.txt")
print(resp.status_code)

# S3 object
resp = session.get("s3://my-bucket/path/to/object.json")
print(resp.status_code)

# OCI artifact
resp = session.get("oci://registry.example.com/my-repo:latest")
print(resp.status_code)

Adapter Notes

Bearer Auth HTTP Adapter

  • Adds an Authorization: Bearer <token> header to every request it handles
  • Replaces an existing Authorization header
  • Can be mounted on a specific URL prefix to limit where the token is sent
  • Mount separate adapters for http:// and https:// if both schemes are needed

File Adapter

  • Supports GET, HEAD, PUT, DELETE
  • Uses local filesystem paths from file:// URLs

S3 Adapter

  • Supports GET, HEAD, PUT, DELETE
  • Supports query options like:
    • range=bytes=0-99
    • versionId=...
    • delimiter=/
    • maxKeys=...

OCI Adapter

  • Supports GET, HEAD, PUT, DELETE
  • Parses refs as tags (:tag) or digests (@sha256:...)
  • Uses oras.client.OrasClient under the hood

Development

Run tests:

hatch run test:test-q

Run lint checks:

hatch run dev:check
ruff format --check .

Preview the documentation:

hatch run docs:serve

Build the documentation with strict validation:

hatch run docs:build

License

License

Apache License, Version 2.0

Metadata

Release files for session-adapters 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for session-adapters 0.6.0
File Size Uploaded
session_adapters-0.6.0.tar.gz 111.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for session-adapters 0.6.0
File Interpreter ABI Platform
session_adapters-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 136.4 kB

Release files / session_adapters-0.6.0.tar.gz

Download URL session_adapters-0.6.0.tar.gz
Size 111.3 kB
Tags Source
SHA-256 checksum
How to use checksums
17cf61723cf920d0820c91298a91fb36e3724beed4f5ea4386f4fdf2bbbb59c8
BLAKE2b-256 checksum
How to use checksums
5e18a01d9f4bce3b16819ba07367987f0e71868ad7afeabf76dfe664900e0c8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release files / session_adapters-0.6.0-py3-none-any.whl

Download URL session_adapters-0.6.0-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d6b5a93c36384b55d9ef6e194eb149915497751d857943f30d7ccd1874d76bb3
BLAKE2b-256 checksum
How to use checksums
0e79b9afbc8604790fba993019ce2b325bab56fa0783addc11947d225a283d2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 28, 2026.

Transparency log

Release history Release notifications | RSS feed

0.7.0

2 release files

This release

0.6.0 This release

2 release files

0.5.0

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page