Skip to main content

A portable local authentication library for AI agents and developer tools

Reason this release was yanked:

Incorrect imports

Project description

authsome

PyPI version Python 3.13+ License: MIT PyPI downloads

OAuth2 and API key management for agents. Local. Headless. Portable.

Authenticate once. Get valid headers anywhere. No server, no account, no cloud.


The Problem

Agents and developer tools need to call APIs. Authentication keeps getting in the way:

  • OAuth2 flows are stateful — browsers, callbacks, token exchange
  • Tokens expire — refresh logic gets reinvented in every project
  • API keys get hardcoded or lost in shell profiles
  • There's no standard answer to: "give me a valid GitHub token right now"

Authsome is a local authentication layer that handles login, logout, and token refresh for your agents and scripts. You ask for headers. You get headers. It's the agent's job to call APIs — it's authsome's job to keep the credentials fresh.


What It Does

  • Login flows — PKCE, Device Code, Dynamic Client Registration, API key prompt
  • Automatic token refresh — tokens are refreshed before expiry, transparently
  • One call for valid headers — always returns a usable Authorization header
  • Subprocess injection — run any command with credentials in its environment
  • Headless-friendly — Device Code flow works in CI, SSH sessions, and remote agents
  • 35 bundled providers — GitHub, Google, OpenAI, Linear, Slack, and more, zero config
  • Portable — follows your ~/.authsome directory; works on any machine you're on

Quick Start

pip install authsome
authsome init
authsome login github      # opens browser, completes OAuth2 PKCE flow
authsome login openai      # prompts for API key
authsome list              # all authenticated services and token status
from authsome import AuthClient

client = AuthClient()

# Always returns a valid, refreshed Authorization header
headers = client.get_auth_headers("github")
# → {"Authorization": "Bearer ghu_..."}

headers = client.get_auth_headers("openai")
# → {"Authorization": "Bearer sk-..."}

# Inject credentials into any subprocess — no env files needed
client.run(["python", "script.py"], providers=["github", "openai"])

Why Authsome

Your agent should call APIs, not manage auth state. Authsome is the authentication layer between your agent and the services it uses — local, offline-capable, and zero-dependency on external infrastructure.

Authsome Manual .env Roll your own
OAuth2 flows (PKCE, Device, DCR) build it
Automatic token refresh build it
35 providers, zero config build it
Headless / CI / SSH varies
Multi-account per provider build it
No server, no account

CLI Reference

# Setup
authsome init                          # initialize ~/.authsome
authsome doctor                        # verify installation health

# Authentication
authsome login github                  # OAuth2 browser flow (PKCE)
authsome login github --flow device    # headless Device Code flow
authsome login openai                  # API key prompt
authsome logout github                 # revoke token remotely + remove locally
authsome remove github                 # remove local state only

# Inspect
authsome list                          # all connections + token status
authsome get github                    # connection metadata (secrets redacted)
authsome get github --show-secret      # reveal token
authsome get github --field status     # extract one field

# Export & run
authsome export github --format shell  # → export GITHUB_TOKEN=...
authsome run --provider openai -- python script.py

All commands support --json for machine-readable output and --profile to switch between credential sets (e.g., personal vs. work).


Bundled Providers

35 providers, ready to use with zero configuration:

Developer & Productivity github · google · linear · okta · zapier · calendly · savvycal · typeform · buffer

AI & Data openai · clearbit · ahrefs · semrush · g2 · keywords-everywhere

Marketing & Email mailchimp · klaviyo · brevo · sendgrid · postmark · resend · beehiiv · instantly · lemlist

Sales & CRM apollo · hunter · intercom · mention-me · rewardful · tolt

Media & Analytics wistia · livestorm · optimizely · x · dub

Add your own by dropping a JSON file in ~/.authsome/providers/<name>.json.


Technical Deep Dive

Architecture

┌─────────────────┐     ┌──────────────┐     ┌────────────────────┐
│   Agent / Tool  │────▶│  AuthClient  │────▶│  Provider Registry  │
│                 │     │              │     │  (bundled + local)  │
└─────────────────┘     └──────┬───────┘     └────────────────────┘
                               │
                        ┌──────┴───────┐
                        │  Auth Flows  │
                        ├──────────────┤
                        │ • PKCE       │  ← browser OAuth2
                        │ • Device Code│  ← headless / CI
                        │ • DCR + PKCE │  ← dynamic client reg
                        │ • API Key    │  ← prompt or env import
                        └──────┬───────┘
                               │
                        ┌──────┴───────┐
                        │   Storage    │
                        ├──────────────┤
                        │ SQLite KV    │  ← per-profile credential store
                        │ AES-256-GCM  │  ← encrypted at rest
                        └──────────────┘

AuthClient is the single entry point. It resolves the right flow per provider, manages token refresh transparently, and delegates persistence to a per-profile SQLite store. Profiles let you isolate credential sets (e.g., personal, work, a specific agent).

Auth Flows

Flow When to Use
pkce Browser-capable environments with a pre-registered OAuth client
device_code Headless servers, CI, SSH sessions — no browser required
dcr_pkce Services supporting Dynamic Client Registration — no pre-registration needed
api_key_prompt Interactive terminal, prompts securely via getpass
api_key_env Import a key already present in an environment variable

Custom Providers

Via JSON (~/.authsome/providers/my-service.json):

{
  "name": "my-service",
  "display_name": "My Service",
  "auth_type": "api_key",
  "flow": "api_key_prompt",
  "api_key": {
    "header_name": "X-API-Key",
    "header_prefix": "",
    "env_var": "MY_SERVICE_KEY"
  }
}

Via Python:

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"),
))

Multiple Connections

Same provider, multiple accounts:

client.login("openai", connection_name="personal")
client.login("openai", connection_name="work")

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

Storage Layout

~/.authsome/
  config.json          # global settings (encryption mode, active profile)
  master.key           # encryption key (chmod 0600)
  providers/           # user-defined provider definitions
  config.json          # global settings (encryption mode, active profile)
  master.key           # encryption key (chmod 0600)
  providers/           # user-defined provider definitions
  profiles/
    default/
      store.db         # credential store (SQLite, values AES-256-GCM encrypted)
      store.db         # credential store (SQLite, values AES-256-GCM encrypted)
      lock             # advisory write lock

Environment Variables

Variable Purpose
AUTHSOME_HOME Override the default ~/.authsome directory


License

MIT — see LICENSE.

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.5.tar.gz (84.9 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.5-py3-none-any.whl (61.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: authsome-0.1.5.tar.gz
  • Upload date:
  • Size: 84.9 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.5.tar.gz
Algorithm Hash digest
SHA256 2faa2a47fbe2dc01189cb5584ae68dee570a6e1c97ef73dd050694eb1a3ce496
MD5 e6727d76dd05087fadbb19697cae75f8
BLAKE2b-256 d5ba17f5ff4c1e7c1f6465d99a1c41726cf59d7fe99aeeb4beb09ee73473f933

See more details on using hashes here.

File details

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

File metadata

  • Download URL: authsome-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 61.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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a2e9e58bbe7fa008960ffbf96792fb83236fd50748afcaf5ebfa78aad2e87da1
MD5 8a548af1b1dfa9e9019ef03090eaa59f
BLAKE2b-256 e0d98d50b5bc5c1d6f081d529da722915ba157d4c26a91656700ad22b1659e01

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