Skip to main content

A portable local authentication library for AI agents and developer tools

Project description

authsome

A portable local authentication library for AI agents and developer tools. Manage third-party credentials locally with encrypted storage, supporting OAuth2 and API key flows.

Built for agents making tool calls to MCP URLs — authsome handles the credential lifecycle so your code just asks for headers.

Install

pip install -e .

Quick Start

from authsome import AuthClient

client = AuthClient()
client.init()  # creates ~/.authsome/ directory structure

# --- API Key provider ---
client.login("openai")  # securely prompts for your key
headers = client.get_auth_headers("openai")
# → {"Authorization": "Bearer sk-..."}

# --- OAuth2 provider (PKCE) ---
client.login("github")  # opens browser for authorization
token = client.get_access_token("github")  # auto-refreshes if expired

# --- Export for shell usage ---
print(client.export("openai", format="shell"))
# → export OPENAI_API_KEY=sk-...

# --- Run a command with injected credentials ---
client.run(["curl", "https://api.github.com/user"], providers=["github"])

CLI Usage

Authsome provides a powerful command-line interface to manage your credentials without writing any code. All commands support the --json flag for machine-readable output.

Basic Commands

# Initialize the store (creates ~/.authsome)
authsome init

# Check the health of your installation
authsome doctor

# List all connected providers and their status
authsome list

Authentication

# Start an authentication flow (will prompt or open browser)
authsome login github

# Revoke your token remotely and remove it locally
authsome revoke github

# Just remove the local credential state
authsome remove github

Retrieving Credentials

# Inspect your local connection metadata (secrets are redacted by default)
authsome get github

# Reveal the secret
authsome get github --show-secret

# Extract a specific field
authsome get github --field status

Exporting and Running

# Output environment variables for your shell
authsome export github --format shell

# Execute a command with injected credentials
authsome run --provider openai -- python script.py

How It Works

┌─────────────┐     ┌──────────────┐     ┌───────────────────┐
│  Your App /  │────▶│  AuthClient  │────▶│  Provider Registry │
│    Agent     │     │              │     │  (bundled + local) │
└─────────────┘     └──────┬───────┘     └───────────────────┘
                           │
                    ┌──────┴───────┐
                    │  Auth Flows  │
                    ├──────────────┤
                    │ • PKCE       │  ← browser-based OAuth
                    │ • Device Code│  ← headless OAuth
                    │ • DCR + PKCE │  ← dynamic client reg
                    │ • API Key    │  ← prompt or env import
                    └──────┬───────┘
                           │
                    ┌──────┴───────┐
                    │   Storage    │
                    ├──────────────┤
                    │ SQLite KV    │  ← per-profile store
                    │ AES-256-GCM  │  ← field-level encryption
                    │ OS Keyring   │  ← master key storage
                    └──────────────┘

Key Concepts

Concept Description
Provider A third-party service definition (e.g., github, openai)
Connection A named credential instance (e.g., personal, work)

Supported Flows

Flow Type Use Case
pkce OAuth2 Browser-capable environments with pre-registered clients
device_code OAuth2 Headless/remote environments
dcr_pkce OAuth2 Dynamic client registration + PKCE
api_key_prompt API Key Interactive secure key input
api_key_env API Key Import from environment variable

Bundled Providers

OAuth2: GitHub, Google, Slack, Notion, Linear

API Key: OpenAI, Anthropic, Tavily, SerpAPI, Resend, Stripe

Multiple Connections

# Same provider, different accounts
client.login("openai", connection_name="personal")
client.login("openai", connection_name="work")

# Retrieve specific connection
headers = client.get_auth_headers("openai", connection="work")

Custom Providers

from authsome import ProviderDefinition, AuthType, FlowType
from authsome.models.provider import ApiKeyConfig

client.register_provider(ProviderDefinition(
    name="my-service",
    display_name="My Service",
    auth_type=AuthType.API_KEY,
    flow=FlowType.API_KEY_PROMPT,
    api_key=ApiKeyConfig(
        header_name="X-API-Key",
        header_prefix="",
        env_var="MY_SERVICE_KEY",
    ),
))

Storage Layout

~/.authsome/
  version              # store format version
  config.json          # global settings (incl. encryption.mode)
  master.key           # encryption key (only in local_key mode)
  providers/           # user-registered provider definitions
  profiles/
    default/
      store.db         # encrypted credential store (SQLite)
      metadata.json    # profile metadata
      lock             # advisory write lock

Encryption Modes

Authsome uses AES-256-GCM for field-level encryption. You choose where the master key lives via config.json:

{
  "encryption": { "mode": "local_key" }
}
Mode Master Key Location Best For
local_key ~/.authsome/master.key (file, 0600 permissions) Headless servers, CI, containers
keyring OS credential manager (macOS Keychain, GNOME Keyring, etc.) Desktop environments

Default is local_key for maximum compatibility.

Security

  • All tokens and API keys are encrypted at rest with AES-256-GCM
  • Master key stored in OS keyring or local file — user's choice
  • Secrets are never printed unless explicitly requested
  • run injects credentials into subprocess env without logging

Environment

Variable Purpose
AUTHSOME_HOME Override the default ~/.authsome directory

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

authsome-0.1.4.tar.gz (81.7 kB view details)

Uploaded Source

Built Distribution

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

authsome-0.1.4-py3-none-any.whl (49.8 kB view details)

Uploaded Python 3

File details

Details for the file authsome-0.1.4.tar.gz.

File metadata

  • Download URL: authsome-0.1.4.tar.gz
  • Upload date:
  • Size: 81.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for authsome-0.1.4.tar.gz
Algorithm Hash digest
SHA256 74953bce7b4d50cedeef761e3a34df852a9e0f48c1a46940cd128ba4022a4602
MD5 5f54dcc6e44136b84bea6205b724cfc5
BLAKE2b-256 562c975f81de38fcad15fae426540edd010a571ba066354b582b9c717b60f8e5

See more details on using hashes here.

File details

Details for the file authsome-0.1.4-py3-none-any.whl.

File metadata

  • Download URL: authsome-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 49.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.7 {"installer":{"name":"uv","version":"0.11.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for authsome-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 650b6781da4cf0664bfc3b9d61dddfa6f689dc644c7412a3b6af3a46f719ee4c
MD5 c83fe040854e9ce7f29d3e9374d4b82d
BLAKE2b-256 946b917c1537e2ac67f0259d117ae00a5631ecc3180668c9da907f8b188dcf81

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