Skip to main content

Minimal TOTP 2FA code generator with clipboard copy and global hotkey support

Project description

openauth-totp

Minimal TOTP 2FA code generator. One command copies your current code to the clipboard. Bind it to a global hotkey for two-keystroke 2FA from any app.

Install

pip install openauth-totp

Or install from source:

git clone https://github.com/rhakim/openauth-totp.git
cd openauth-totp
pip install .

Quick start

# 1. Save your Base32 secret (one-time)
openauth --setup

# 2. Copy current code to clipboard
openauth

That's it. Run openauth whenever you need a code, then paste it.

Requirements

  • Python 3.10+ (only the standard library — zero pip dependencies)
  • A clipboard tool (built-in on macOS and Windows):
    • macOS: pbcopy (pre-installed)
    • Windows: clip (pre-installed)
    • Linux: xclip or xsel (sudo apt install xclip)
  • A browser (optional, only for --gui mode):
    • Chrome or Chromium gives a clean app-style window (no tabs/URL bar)
    • Any other browser works too, just opens as a normal tab

Usage

Command Description
openauth Generate code, copy to clipboard, show notification
openauth --setup Save your Base32 secret key
openauth --print Print code to stdout (no clipboard, no notification)
openauth --next Copy the next code (one 30s period ahead)
openauth --gui Open the browser-based visual interface

Global hotkey setup

The real power is binding openauth to a keyboard shortcut so you can copy a 2FA code from any app without switching windows.

macOS (Shortcuts app — no extra software)

  1. Open Shortcuts.app
  2. Create a new shortcut
  3. Add a Run Shell Script action
  4. Set the command to the full path (find it with which openauth):
    /path/to/openauth
    
  5. Click the shortcut name at the top → click (info) → Add Keyboard Shortcut
  6. Press your desired key combo (e.g. Ctrl+Shift+O)

Now from any app: press your hotkey, then Cmd+V to paste.

Windows (AutoHotkey)

Install AutoHotkey, then create a script:

^+o::  ; Ctrl+Shift+O
Run, openauth, , Hide
return

Linux (GNOME / KDE / etc.)

Add a custom keyboard shortcut in your desktop environment's settings:

  • Command: openauth
  • Shortcut: your choice (e.g. Ctrl+Shift+O)

GUI mode

openauth --gui

Opens a small browser-based interface showing the live code with a countdown. Keyboard shortcuts work when the window is focused:

Key Action
C or Cmd/Ctrl+C Copy code to clipboard
N Toggle next code
Esc Back to settings
Double-click code Copy to clipboard

Chrome/Chromium opens this as a standalone window (no tabs or URL bar). Other browsers open it as a regular tab — functionally identical.

How it works

Standard TOTP (RFC 6238):

  • HMAC-SHA1 with a 30-second time step
  • 6-digit codes
  • Base32-encoded secret key
  • Compatible with Google Authenticator, Duo, 1Password, and any TOTP-based 2FA

Where the secret is stored

CLI mode: ~/.config/openauth/secret with chmod 600 permissions. This is a plain file — similar to how ~/.ssh/ stores keys. Protect your machine, and the secret is safe.

GUI mode: Encrypted with AES-256-GCM in the browser's localStorage. The decryption key is a non-extractable CryptoKey in IndexedDB (cannot be exported via JavaScript). The secret is never stored in plaintext in the browser.

Attribution

This codebase was largely vibecoded using Claude Code with Opus 4.6

Other

If you are using this for the Harvard FAS cluster. Visit this site to request your setup token: https://docs.rc.fas.harvard.edu/kb/openauth/.

License

MIT

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

openauth_totp-0.1.0.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

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

openauth_totp-0.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file openauth_totp-0.1.0.tar.gz.

File metadata

  • Download URL: openauth_totp-0.1.0.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for openauth_totp-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e46873c2f2cae9ca339e762e5fa88c9ba8194e7c1ef30b603070c09cdcd501f7
MD5 774ce7c0a6e679246a6953d4bb666ec9
BLAKE2b-256 5afb3a98d53ffe447cc417781913aff5ea4f09aaa7fa5a33b0d3aceb0755117c

See more details on using hashes here.

Provenance

The following attestation bundles were made for openauth_totp-0.1.0.tar.gz:

Publisher: pypi_release.yml on RichieHakim/openauth-totp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file openauth_totp-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: openauth_totp-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for openauth_totp-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a08a94ae58bba735060f8d78eefea476c5af26ac1e4ea2532844f812ace4d887
MD5 e3fe38e2f85abae5c228cd690c11b106
BLAKE2b-256 b9094ff7a43baaf251404aee12d693afee597e4aea5c5ee4de6d6b5655486fd1

See more details on using hashes here.

Provenance

The following attestation bundles were made for openauth_totp-0.1.0-py3-none-any.whl:

Publisher: pypi_release.yml on RichieHakim/openauth-totp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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