Skip to main content

Automated authentication for web agents

Project description

AgentAuth

AgentAuth is a Python package that helps automate web authentication by simulating human-like login behavior. It supports various authentication methods including:

  • Standard username/password login
  • Time-based One-Time Passwords (TOTP)
  • Email magic links
  • Email verification codes

Features

  • 🤖 Automated Authentication: Handles complex login flows automatically
  • 📧 Email Integration: Supports email-based verification (magic links and codes)
  • 🔐 Password Manager Integration: Works with 1Password, Bitwarden, and local credential storage
  • 🌐 Browser Integration: Compatible with remote CDP-based browsers

Installation

pip install agentauth

Quick Start

from agentauth import AgentAuth, CredentialManager

# Add credentials to a new credential manager
credential_manager = CredentialManager()
credential_manager.load_credential({
    "website": "https://www.example.com",
    "username": "user@example.com",
    "password": "user_password"
})

# Create an instance of AgentAuth with access to credentials
aa = AgentAuth(credential_manager=credential_manager)

# Authenticate to a website for a given username
cookies = await aa.auth("https://www.example.com", "user@example.com")

# User is logged in! 🎉
# Use cookies for authenticated agent actions... (see examples directory to see how)

ℹ️ You can pass a custom LLM to the AgentAuth constructor. OpenAI's gpt-4o is the default and requires an OPENAI_API_KEY environment variable.

Connecting an email inbox

Many websites require an email step to authenticate. This could be for a magic link or login code, or it could be for email-based two-factor authentication. AgentAuth supports connecting an email inbox to handle these cases.

aa = AgentAuth(
    imap_server="imap.example.com",
    imap_username="agent@example.com",
    imap_password="agent_email_password"
)

cookies = await aa.auth("https://www.example.com", "agent@example.com")

Loading credentials from various sources

from agentauth import AgentAuth, CredentialManager

# Create a new credential manager
credential_manager = CredentialManager()

# Load credentials from 1Password
credential_manager.load_1password(os.getenv("OP_SERVICE_ACCOUNT_TOKEN"))

# Load credentials from Bitwarden
credential_manager.load_bitwarden(
    os.getenv("BW_CLIENT_ID"),
    os.getenv("BW_CLIENT_SECRET"),
    os.getenv("BW_MASTER_PASSWORD")
)

# Load credentials from a file
credential_manager.load_file("credentials.json")

# Load a single credential
credential_manager.load_credential({
    "website": "https://www.example.com",
    "username": os.getenv("USERNAME"),
    "password": os.getenv("PASSWORD")
})

# Load a list of credentials
credential_manager.load_credentials([
    {
        "website": "https://www.example.com",
        "username": os.getenv("EXAMPLE_USERNAME"),
        "password": os.getenv("EXAMPLE_PASSWORD")
    },
    {
        "website": "https://www.fakewebsite.com",
        "username": os.getenv("FAKEWEBSITE_USERNAME"),
        "password": os.getenv("FAKEWEBSITE_PASSWORD")
    }
])

To Do

  • Add automatic publishing to PyPI
  • Support local S/LLM for email scanning
  • Add support for other password managers

Contributing

Contributions are welcome! Please feel free to submit a pull request.

License

This project is licensed under the MIT 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

agentauth-0.4.0.tar.gz (114.9 kB view details)

Uploaded Source

Built Distribution

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

agentauth-0.4.0-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

Details for the file agentauth-0.4.0.tar.gz.

File metadata

  • Download URL: agentauth-0.4.0.tar.gz
  • Upload date:
  • Size: 114.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.29

File hashes

Hashes for agentauth-0.4.0.tar.gz
Algorithm Hash digest
SHA256 d971688e1c80fb93298a89e9f07e2fec03e63931d897ab0f318553854df5a104
MD5 e2764219623b18d573dd6d6a4adc8c6a
BLAKE2b-256 838a1a0e54c14a6952230e72a263a7e7040c272958b53951c59a035f3d037b47

See more details on using hashes here.

File details

Details for the file agentauth-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: agentauth-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 12.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.29

File hashes

Hashes for agentauth-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1c6c3ef5ec06cfe8c44f89e0ffa51ce85461593d8936f951c948ea316e74c8d3
MD5 9582c39c703a7c08aac039b612b0514d
BLAKE2b-256 6ef6f1008d1fcf0f2d3555e5c65df030eeaccc868d5fb6c1f8c7d289e8daabbf

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