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.3.tar.gz (81.4 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.3-py3-none-any.whl (49.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: authsome-0.1.3.tar.gz
  • Upload date:
  • Size: 81.4 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.3.tar.gz
Algorithm Hash digest
SHA256 2f5241df098a5c103a412b7b35bc588d31c4ec8341471abfb40d46d51fc5b17b
MD5 fbd73282eba0a93f61a4bff6a758cf93
BLAKE2b-256 ccccdba2c7952f2cdb3d451e317b1a989a7772a6e041445aa2dbb0ce71f658d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: authsome-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 49.6 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.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a3c0688eb20d3f371e48e16a48158b2e6730a07bdd6cb6b5f1641a140c9b1479
MD5 607a108148738c055fc3ba248be5e7a5
BLAKE2b-256 e47b0f18c87ec6ee0a8d8846b3e31c6f4712570eada9542d4a58d3044bc5745e

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