Skip to main content

Infilake OpenAPI Authorization SDK for generating HMAC-SHA256 signed headers

Project description

Infilake OpenAPI Auth SDK

Authorization SDK for generating HMAC-SHA256 signed headers.

Installation

Using pip

pip install infilake-openapi-auth

Using uv

# Install uv (if not already installed)
# Windows: powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
# macOS/Linux: curl -LsSf https://astral.sh/uv/install.sh | sh

# Create virtual environment and install
uv venv
uv pip install .

# Or install in development mode
uv pip install -e .

Install from source

pip install .

Development Setup with uv

# Create virtual environment with specific Python version
uv venv --python 3.11

# Activate virtual environment
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate

# Install with dev dependencies
uv pip install -e ".[dev]"

# Or use uv sync (reads pyproject.toml)
uv sync

# Run tests
uv run pytest

Usage

from infilake_openapi_auth import AuthSDK

# Initialize with your secret key
sdk = AuthSDK("your-secret-key")

# Generate headers for a request
headers = sdk.get_headers("/api/v1/resource", "POST")
print(headers)
# {'X-Timestamp': '20260116T104530Z', 'X-Authorization': 'base64...'}

# Use with requests library
import requests

url = "https://api.example.com/api/v1/resource"
auth_headers = sdk.get_headers("/api/v1/resource", "GET")
response = requests.get(url, headers=auth_headers)

API

AuthSDK(hmac_secret: str)

Initialize the SDK with your HMAC secret key.

sdk.sign(sign_url: str, request_action: str = "GET") -> AuthResult

Generate authorization signature. Returns an AuthResult object with:

  • x_timestamp: The timestamp used for signing
  • x_authorization: The Base64-encoded HMAC-SHA256 signature

sdk.get_headers(sign_url: str, request_action: str = "GET") -> dict

Generate headers dict ready for HTTP requests. Returns:

{
    "X-Timestamp": "...",
    "X-Authorization": "..."
}

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

infilake_openapi_auth-1.0.0.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

infilake_openapi_auth-1.0.0-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

Details for the file infilake_openapi_auth-1.0.0.tar.gz.

File metadata

  • Download URL: infilake_openapi_auth-1.0.0.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.3

File hashes

Hashes for infilake_openapi_auth-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7b044fdc80d600e2c285d132236901ca63d53ca5f134180d24c2d34e29ff41f2
MD5 7f891d7d68a36ddd96eb9f19844b43b8
BLAKE2b-256 5933867832441d01e84dfc5074bdcc26e8fa5a6bbe5a7a5ad932130cd6b85cfd

See more details on using hashes here.

File details

Details for the file infilake_openapi_auth-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for infilake_openapi_auth-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2adf11ce40139cea3a65ee912d1a1b1860b044212e57f32e8fbe47f3c6780ea1
MD5 60b1f8118e3ae578bf1a2290c9f08808
BLAKE2b-256 c734e094e2c85ff7c3971d7d0ee88de542292ebf24e200eced43ed53dda3afbe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page