Skip to main content

A portable local authentication library for AI agents and developer tools

Reason this release was yanked:

incorrect init

Project description

authsome

PyPI version Python 3.13+ License: MIT PyPI downloads

OAuth2 and API key management for agents. Local. Headless. No SaaS.

Your agent calls APIs. Authsome keeps the credentials fresh.


The Problem

Agents need to call APIs. The current answers are all wrong for agents:

  • Hardcode a PAT in .env — works until the token expires, rotates, or leaks
  • Write OAuth2 yourself — ~200 lines of flow logic, token storage, and refresh handling per project, using authlib or requests-oauthlib, reinvented every time
  • Nango — full OAuth infrastructure, but it's a SaaS service with a server you have to run or pay for

None of these are designed for agents. They assume a browser, a web server, or a human in the loop at runtime.

Authsome is a local credential layer your agent invokes at runtime. Authenticate once, headlessly. After that, your agent asks for headers and gets them.


How It Works

The CLI is the agent's interface — for setup and for runtime use.

Authenticate once:

authsome login github

Then the agent gets a valid, automatically-refreshed token on demand:

authsome get github --field access_token
# → ghu_...

authsome export github --format shell
# → export GITHUB_TOKEN=ghu_...

authsome run --provider github --provider openai -- python my_agent.py
# runs the script with GITHUB_TOKEN and OPENAI_API_KEY injected

Credentials are stored locally, encrypted at rest (AES-256-GCM), and refreshed before expiry. No server. No account. No cloud.


Why Authsome

authsome Hardcoded env tokens DIY (authlib) Nango
OAuth2 flows (PKCE, Device Code, DCR) build it
Automatic token refresh build it
Headless (CI, SSH, no browser) varies ⚠️
Local — no SaaS dependency
35 providers, zero config
Multi-account per provider build it
One call for valid token build it

vs. DIY (authlib / requests-oauthlib): authlib handles the HTTP exchange, but you still write the token store, refresh logic, expiry handling, and per-provider config — then repeat it for every project. Authsome eliminates that boilerplate entirely.

vs. Nango: Nango is the closest conceptual peer — it manages OAuth for you across many providers. The difference: Nango requires a hosted server (or their SaaS). Authsome runs locally, follows your ~/.authsome directory, and has no external dependencies. It's the right choice when your agent runs on machines you control and you don't want infrastructure you don't own in the auth path.


Quick Start

pip install authsome
authsome init
authsome login github                  # opens browser, completes PKCE flow
authsome login github --flow device    # headless: Device Code, works over SSH and CI
authsome login openai                  # prompts for API key
authsome list                          # all connections + token status

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 & inject
authsome export github --format shell  # → export GITHUB_TOKEN=...
authsome run --provider openai -- python my_agent.py

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


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  │────▶│     CLI      │────▶│  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
                        └──────────────┘

The CLI resolves the right flow per provider, manages token refresh transparently, and persists credentials in 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
api_key_env Import a key already present in an environment variable

Custom Providers

Drop a JSON file at ~/.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"
  }
}

Then use it like any bundled provider:

authsome login my-service
authsome get my-service --show-secret

Multiple Connections

Same provider, multiple accounts:

authsome login openai --connection personal
authsome login openai --connection work

authsome get openai --connection work --show-secret
authsome run --provider openai --connection work -- python my_agent.py

Storage Layout

~/.authsome/
  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)
      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.7.tar.gz (85.2 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.7-py3-none-any.whl (61.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: authsome-0.1.7.tar.gz
  • Upload date:
  • Size: 85.2 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.7.tar.gz
Algorithm Hash digest
SHA256 9d373b16c57cf3c266f8a69b957bf68f612301ba494d0839198c760d5503dbbc
MD5 13c2309377512ad57cbc778a401a4fc0
BLAKE2b-256 6e694c7cc6884142229297b4cbc853b72f0f0410953068c95ca1dbf2299ce5e5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: authsome-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 61.3 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.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7b0375ac3c31a02f26b56f09f84d60703ec7696d649512ee36d115ba5c821be8
MD5 0f347dbfbbe68764e463ce2102e66e26
BLAKE2b-256 14d20aa9ac5795eb3d73e426a4ff29bffead97149bf06a209af08140df8df082

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