DEV Community

Jenil Pokar
Jenil Pokar

Posted on

I built a CLI tool that auto-copies OTPs from Gmail — no more tab switching

*Every time I needed to log into something, the same thing happened:
*

  1. Enter email and password
  2. Wait for the OTP email
  3. Switch to Gmail
  4. Find the email
  5. Copy the 6-digit code
  6. Switch back
  7. Paste it before it expires

It's maybe 15 seconds. But it happens dozens of times a day, and it's
just annoying enough to break focus every single time.

So I built OTPilot.

What it does

OTPilot runs silently in the background. When you press a hotkey
(default: Ctrl+Shift+O), it:

  1. Fetches your last 10 emails from Gmail
  2. Finds the OTP
  3. Copies it to your clipboard
  4. Shows a desktop notification

That's it. No tab switching. No waiting. Just paste.

How to install

pip install otpilot

Requirements:

  • Python 3.8+
  • Gmail account
  • Google Cloud project with Gmail API enabled (free, one-time 5 minute setup)

How to set it up

otpilot setup

The setup wizard walks you through:

  • Importing your Google credentials
  • One-time Gmail sign-in (OAuth — read-only access)
  • Setting your preferred hotkey

Then run:

otpilot start

It sits in your system tray and waits.

Privacy

This was my main concern when building it.

  • Your credentials never leave your machine
  • Gmail access is read-only — it cannot send, delete, or modify anything
  • Emails are fetched only when you press the hotkey — no background polling
  • OAuth tokens are stored locally at ~/.otpilot/

The Google Cloud setup

The one friction point is the one-time Google Cloud setup to get a
credentials.json file. It takes about 5 minutes and the full guide is
in the repo. Once it's done, you never touch it again.

Platforms

Works on macOS, Linux, and Windows.

Linux users need xclip or xsel for clipboard support:

sudo apt install xclip

Links

MIT licensed. Feedback and contributions welcome — especially around
OTP extraction patterns, since different services format their emails
differently.

Top comments (0)