| Approach | Best for | Complexity |
|---|---|---|
| Profiles (login once) | Sites with long-lived cookies | Lowest |
| Human in the loop | One-off tasks, complex auth flows | Low |
| Agent Mail | Email-based 2FA, end-client automation | Medium |
| TOTP secret in prompt | Authenticator app 2FA (Google Authenticator, Authy) | Medium |
1. Profiles — login once, reuse cookies
Login manually once (or let the agent do it), then save the browser state as a profile. Future sessions reuse the cookies — no 2FA prompt as long as the cookies are valid.2. Human in the loop
Let the agent navigate to the login page, then a human takes over to complete 2FA via the live browser view. The agent continues after.3. Agent Mail
When 2FA sends a code via email, the agent can read it automatically using Agent Mail — a built-in email inbox for each session. Agent Mail is enabled by default (agentmail=True). Each session gets a unique email address (session.agentmail_email). The agent can send and receive emails during the task.
For end-client automation
If you’re automating on behalf of your users and they need to receive 2FA codes:- Email forwarding: Have your client set up an email forwarding rule — forward all emails from the service (e.g.,
noreply@bank.com) to a dedicated inbox (a Gmail address or an Agent Mail address). - Give the agent access: The agent reads the forwarded 2FA code from that inbox during the task.
Connect external email via Composio
You can also give the agent access to an existing Gmail account using Composio in the Browser Use dashboard. Once connected, the agent can read emails directly from that account to retrieve 2FA codes.4. TOTP secret in prompt
If the site uses an authenticator app (Google Authenticator, Authy, etc.), you can pass the TOTP secret to the agent. Our agent can execute Python code, so it uses thepyotp library to generate fresh 6-digit codes on the fly.
When you set up 2FA on a site, instead of only scanning the QR code, also copy the secret key (usually shown as “manual entry” or “can’t scan the QR code?”). This is a long base32 string like JBSWY3DPEHPK3PXP.
pyotp.TOTP(secret).now() to generate a time-based 6-digit code, then types it into the 2FA field.
Where to find TOTP secrets
- 1Password: Edit item → One-Time Password → Show secret
- Google Authenticator: During setup, click “Can’t scan it?” to see the key
- Authy: Export via desktop app settings
- Most sites: Look for “manual entry” or “setup key” during 2FA enrollment
Which approach should I use?
I'm automating my own accounts
I'm automating my own accounts
Start with Profiles — log in once, reuse cookies. If cookies expire frequently, add TOTP secret in prompt for fully automated re-login.
I'm building a product for end-users
I'm building a product for end-users
Use Profiles with one profile per user. For initial login, use Human in the loop — your user logs in once via the live view, then the agent reuses the session. For email 2FA, set up Agent Mail with email forwarding from your user.
I need to handle email verification codes
I need to handle email verification codes
Use Agent Mail (enabled by default). For end-client scenarios, have them forward 2FA emails to a dedicated inbox.
I need fully autonomous 2FA without any human
I need fully autonomous 2FA without any human
Use TOTP secret in prompt — the agent generates codes via pyotp, no human intervention needed.