2FA codes, handled by the agent.

Authenticator codes from the secret, emailed codes from an inbox the run owns, SMS forwarded to that inbox, or 1Password typing the field. Then a saved profile so the site stops asking.

One login saved as a browser profile with cookies and logins, then reused by browser 2 and browser 3
Log in once. Every browser that loads the profile starts inside.
ways the agent gets a code without a person
4
login, then profiles reuse it
1
passwords and TOTP with secret bindings; the model sees aliases
Server-typed

Four ways to get the code.

A TOTP secret makes the agent its own authenticator app. An inbox of its own catches emailed codes. SMS forwards into that inbox. A 1Password vault types username, password and TOTP on the allowed domains. Pick the one the site uses; the code panel has each.
from browser_use import Agent, ChatBrowserUse # The secret from "can't scan the QR code", not a 6-digit code.# Any placeholder ending in bu_2fa_code becomes a fresh code when typed.agent = Agent(    task="Log in to https://example.com, enter x_user and x_pass, "         "then enter bu_2fa_code when asked for 2FA",    sensitive_data={        "x_user": "ada",        "x_pass": "correct horse battery staple",        "bu_2fa_code": "JBSWY3DPEHPK3PXP",    },    llm=ChatBrowserUse(),)await agent.run()
totp.pyTOTP · Email · SMS · 1Password · Profiles

Log in once. Save the profile.

After the first login, save the profile. Cookies, localStorage and login state come back on every later run or standalone browser, so the site does not challenge again while they are valid. Already logged in on your laptop? Sync those cookies into a profile with one command and skip the first login too. Works for Playwright sessions at $0.06 per browser-hour as well as for agent runs.

Keep logins across runs.

Your own Playwright scripts: Playwright's built-ins are enough. Agent runs: Browser Use, local or cloud.
  • Playwright storageState

    Persists
    Cookies and localStorage. IndexedDB with indexedDB: true. Not sessionStorage.
    Lives in
    A JSON file: context.storageState({ path }), reloaded with newContext({ storageState })
    Use when
    Your scripts, tests and CI.
  • Playwright persistent context

    Persists
    The whole user data folder, cookies and local storage included.
    Lives in
    A folder: launchPersistentContext(userDataDir)
    Use when
    Local, one browser per folder.
  • Browser Use library

    Persists
    Cookies, saved periodically and on shutdown, in Playwright's file format.
    Lives in
    A JSON file: Browser(storage_state='session.json')
    Use when
    Agent runs you host.
  • Browser Use Cloud profile

    Persists
    Cookies, local storage and login state, saved when the browser stops.
    Lives in
    On our servers, by id: profileId
    Use when
    Cloud runs, one profile per end user.

Sources: Playwright auth, storageState, launchPersistentContext, Browser Use library, Cloud profiles, checked Oct 2026.

Which method fits which site

Authenticator app
sensitive_data placeholder ending in bu_2fa_code with the TOTP secret. Or the TOTP field of a 1Password item.
Emailed code
agentmail: true on the run. The agent owns an inbox and reads the code. Open source: AgentMail tools or the Gmail integration.
SMS code
Forward texts to an inbox (carrier, Google Voice, Twilio to email), then treat it as an emailed code.
Password manager
opVaultId and opVaultAllowedDomains, or per-field secretBindings. Server-typed, model sees aliases.
Already logged in
profileId on runs and browsers. curl -fsSL https://browser-use.com/profile.sh | sh syncs your Chrome's cookies into one.
Price
Agent runs bill model tokens plus browser time at $0.06 per hour; standalone browsers $0.06 per hour, residential proxy $5/GB.
Keep it contained
allowed_domains and prohibited_domains limit navigation. use_vision=False keeps screenshots of sensitive pages away from the model.

Questions people ask

Which kind of 2FA can the agent do by itself?

Authenticator-app codes, from the TOTP secret. Emailed codes, from an inbox the run owns or from Gmail. SMS codes, once the number forwards to an inbox. Codes stored in 1Password. The only kind that needs a person is a push notification to someone else's phone.

How do I keep cookies and logins across runs?

Playwright: storageState saves cookies and localStorage to a file; launchPersistentContext keeps a whole user data folder. Browser Use: storage_state='session.json' in the library, a profileId on Cloud.

How does the TOTP part work?

When you set up 2FA a site shows a secret key under 'can't scan the QR code'. Give that secret to the agent as a sensitive_data value whose name ends in bu_2fa_code. When the agent types the placeholder, a fresh six-digit code is generated. The model never sees the secret.

How does the email part work?

Set agentmail to true on a V4 run and the run gets a persistent inbox from AgentMail. The address is in the agent's context, so it can sign up with it, wait for the verification email, and read the code. The open-source library does the same through AgentMail tools or the built-in Gmail integration.

And SMS?

Forward the number's texts to an inbox the agent can read: carrier forwarding, Google Voice, or a Twilio number that emails you. From there it is an emailed code.

Do I have to do this on every run?

No. Log in once, save a profile and pass its id. The site usually skips the login while the cookies are valid; some sites still re-verify or bind the session to a device or network.

Does the model see my password?

With secret bindings or 1Password, the server types the value and the model works with an alias; the raw value never sits in the task text. Once typed it is on the page like any input, so keep bindings scoped to the hosts that need them. Browser Use does not store browser passwords.

When would a person still be needed?

Push-approval 2FA on a phone you do not control, or a bank that insists on a human. A run can pause at that step and hand the live view to someone; the session continues after.