I Built a Zero-Dependency Python Library for OTP Codes

작성자

카테고리:

← 피드로
DEV Community · fajardev-tech · 2026-06-26 개발(SW)

fajardev-tech

The Problem

Every automation project hits the same wall: OTP verification.

You’re building a bot, a scraper, an automation tool — and then you need to verify an account. GitHub, Google, Discord, OpenAI… they all want a code sent to your email.

Your options:

  • SMS gateways — cost money, rate limited
  • Third-party APIs — another dependency, another failure point
  • Manual copy-paste — defeats the purpose of automation

The Solution: otp-gateway

otp-gateway reads OTP codes directly from your inbox via IMAP.

pip install otp-gateway

Enter fullscreen mode Exit fullscreen mode

No API keys. No external services. Just IMAP.

Quick Start

from otp_gateway import OTPGateway, OTPConfig

config = OTPConfig(
    imap_email="[email protected]",
    imap_password="your-app-password",
    domain="yourdomain.com",
)

gw = OTPGateway(config)

# Generate an alias for the platform
alias = gw.generate_alias("github")
print(alias)  # "[email protected]"

# Use this email to sign up, then wait for the OTP
result = gw.wait_for_otp(alias, timeout=90)
print(result["value"])  # "847291"

Enter fullscreen mode Exit fullscreen mode

Features

  • 13 OTP extraction patterns — digits, alphanumeric, multi-language
  • 30+ platform support — GitHub, Google, Discord, OpenAI, Anthropic, AWS, Azure, and more
  • Verification link extraction — not just codes, but links too
  • Alias generation — create unique emails for each platform
  • Smart dedup — never returns the same OTP twice
  • CLI includedotp-gateway wait [email protected]
  • Zero dependencies — only Python stdlib

Why Zero Dependencies?

In automation, every dependency is a risk:

  • Version conflicts break your pipeline
  • Supply chain attacks compromise your system
  • Deployment complexity slows you down

otp-gateway uses only Python’s standard library. Copy the otp_gateway/ folder into your project and it works.

CLI Usage

# Wait for an OTP
$ otp-gateway wait [email protected]
⏳ Waiting for OTP at [email protected]...
✅ OTP found: 847291 (GitHub)

# Check for recent OTPs
$ otp-gateway check --email [email protected] --since 5m

# Generate an alias
$ otp-gateway alias github
[email protected]

Enter fullscreen mode Exit fullscreen mode

Supported Platforms

GitHub, Google, Discord, OpenAI, Anthropic, DeepSeek, AWS, Azure, Vercel, Netlify, Cloudflare, DigitalOcean, HuggingFace, Stripe, and 15+ more. The pattern library is easily extensible.

Get Started

pip install otp-gateway

Enter fullscreen mode Exit fullscreen mode

MIT licensed. PRs welcome.

If you build automation tools, give it a try. If you find it useful, a star on GitHub means a lot.

원문에서 계속 ↗

코멘트

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다