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?
- · A seed in an env var or prompt can generate codes forever — anyone who reads your logs, traces or repo can log in.
- · With OTPilot the agent holds a revocable, rate-limited key scoped to specific accounts. Revoke it and access ends instantly.
- · Each fetch is logged with the reason the agent gave, and sensitive accounts can require a human tap.
Browser Use 2FA guides by site
- Amazon 2FA with Browser Use→
- Amazon Web Services 2FA with Browser Use→
- Cloudflare 2FA with Browser Use→
- DigitalOcean 2FA with Browser Use→
- GitHub 2FA with Browser Use→
- GitLab 2FA with Browser Use→
- HubSpot 2FA with Browser Use→
- Microsoft Azure 2FA with Browser Use→
- PayPal 2FA with Browser Use→
- Shopify 2FA with Browser Use→
- Slack 2FA with Browser Use→
- Stripe 2FA with Browser Use→
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.