Skip to content
Browserbase
    • Primitives
      • BrowsersCloud browsers for your agent to use the web
      • AgentsScale fully managed browser agents with simple prompts
      • SearchFind relevant websites from a single query
      • FetchRetrieve web data as agent-ready HTML, JSON, or markdown
      • RuntimeScalable, sandboxed environments for agent deployments
      • IdentityAuthenticate your agent to navigate the web like a human
      • ModelsUse any model with a single API key
      • ObservabilityUnified debugging your agent across replays, logs, and prompts
    • Open Source
      • Browse CLIGive your agent browsing skills with a single command
      • StagehandThe most popular AI browser automation framework
    • Use Cases
      • Browser Agents
      • Automated Testing
      • Workflow Automation
      • Web Data Extraction
      All use cases
    • Industries
      • AI & Agent Platforms
      • Healthcare
      • Fintech
      • GTM
      • Legal
    • Resources
      • Blog
      • Customers
      • Enterprise
      • Templates
  • Pricing
  • Docs
  • Log in
Log in
Sign up
Get a demo

MFA handling: TOTP code generation

Automate MFA completion using TOTP code generation with RFC 6238 compliant algorithm

MFA handling: TOTP code generation demo

Works with

TypeScriptTypeScriptPythonPythonStagehandStagehand

Built by

Browserbase

Support

support@browserbase.com

Resources

Browserbase docsStagehand websiteStagehand docs
Copy prompt to run with your AI agent
npx create-browser-app --template mfa-handling
uvx create-browser-app --template mfa-handling

Send this template to your email, or view it on your desktop for the source code.

Get started automating TOTP-based MFA authentication

This template automates Multi-Factor Authentication (MFA) completion using Time-based One-Time Password (TOTP) code generation. It implements the RFC 6238 compliant algorithm to generate 6-digit codes programmatically, extracts TOTP secrets from pages, and automatically fills MFA forms without user interaction. The template includes retry logic to handle time window edge cases and automatically regenerates codes when authentication fails. Perfect for automated authentication workflows and `zero-touch` MFA completion.

Steps

  1. Navigate to the authentication page with TOTP challenge
  2. Extract test credentials (email, password) and TOTP secret from the page
  3. Generate TOTP code using RFC 6238 algorithm (HMAC-SHA1, 30-second windows)
  4. Fill in email and password fields using Stagehand act
  5. Fill in TOTP code field with the generated code
  6. Submit the authentication form

Most Popular Templates

Search business registries for KYC

Search business registries and extract registration details, NAICS codes, and ownership data

Search business registries for KYC

AI browser agent: Gemini 2.5

Execute autonomous web tasks using Google's Gemini 2.5 computer use model

AI browser agent: Gemini 2.5

Scrape calendar events

Extract structured event data from public calendars including names, dates, and times

Scrape calendar events
Browserbase

Primitives

  • Browsers
  • Web APIs
  • Runtime
  • Identity
  • Model Gateway
  • Observability
  • Stagehand
  • MCP

Industries

  • AI
  • Healthcare
  • GTM
  • Tax
  • Legal

Developers

  • Docs
  • Templates
  • APIs & SDKs
  • Changelog
  • Status
  • Github

Company

  • Careers
  • Customers
  • Partner with Us
  • Trust & Security

Community

TwitterLinkedinYoutube
  • Privacy Policy
  • Terms of Service

Community

TwitterLinkedinYoutube
  • Privacy Policy
  • Terms of Service