OTPilot

Framework guide

Handle 2FA and OTP codes in Browser Use automatically

Give the Browser Use agent a custom action that fetches the current code when a login asks for it. OTPilot keeps the TOTP seed encrypted on its side; your Browser Use agent only ever receives the current code, its expiry and the next code.

Browser Use · python
# pip install browser-use httpx
import os, httpx
from browser_use import Agent, Tools

tools = Tools()

@tools.action("Get the current 2FA authenticator code for Shopify")
def get_2fa_code(account: str = "shopify") -> str:
    r = httpx.get(
        f"https://otpilot.vibiz.app/api/v1/codes/{account}",
        headers={"Authorization": f"Bearer {os.environ['OTPILOT_KEY']}"},
        params={"reason": "Browser Use login"},
    )
    r.raise_for_status()
    data = r.json()
    if data["status"] == "pending":
        return "Approval pending - wait 5 seconds and call get_2fa_code again"
    return data["code"]

agent = Agent(
    task="Log into Shopify. When asked for an authenticator code, call get_2fa_code.",
    llm=llm,  # your model
    tools=tools,
)
await agent.run()

Why not put the seed in your Browser Use code?

Browser Use 2FA guides by site

All 150 sites →

Try it with your own secret — no signup

Paste a TOTP secret on the home page and get a live code plus a working API call in seconds.