AI agents and TOTP / 2FA

Search Console surfaces queries like ai agent totp api and ai agent read only api access on an article about OAuth and API keys, because both are about authority, but TOTP is a different gate. TOTP protects interactive human login. Agents need machine credentials with explicit scopes.

Short answer: never put a TOTP seed or live authenticator output in agent config, prompts, or tool schemas. Prefer a vendor's service account, OAuth with refresh (read-only scopes where possible), or a broker that holds human consent. When the only path is a browser login with 2FA, a human completes the MFA step and the agent receives a already-established session or token, not the seed.

For the full third-party API build sequence (PKCE, refresh rotation, brokers), start with let an AI agent authenticate with third-party APIs securely (post 24). This page is the TOTP / 2FA supplement only. Broader OAuth buyer checklist: OAuth for AI agents. Secret hygiene: secret management for AI agents.

Why sharing a TOTP seed with an agent fails

A TOTP seed is equivalent to a password that rotates every thirty seconds. Feeding it to an agent copies it into logs, crash dumps, tool traces, and model context, the same leak paths that make raw API keys unsafe.

Storing the seed in a vault helps only if the agent never reads the seed, only requests a signature or a one-time broker call. If the runtime injects the current six-digit code into a browser automation step, any prompt injection or screen capture path can exfiltrate it.

Read-only API access is the right goal when the task is pull data. Ask the vendor for a token scope that cannot mutate state, not for credentials that unlock the admin UI.

Patterns for 2FA-protected accounts

PatternWhen it worksAgent risk
Service account / machine userVendor issues API keys or OAuth without interactive MFALow, if scoped and rotated
OAuth with narrow scopesUser consents once; agent uses refresh via brokerMedium, depends on scope width
Human-in-the-loop loginHuman completes MFA; agent gets session or delegated tokenMedium, session theft if mishandled
Shared TOTP seed in agent envAlmost neverCritical, seed in prompts and logs
RPA typing OTP from vault each runLegacy systems onlyHigh, vault becomes hot path for exfiltration

Practical checklist

Ask the vendor for machine auth first

Before automating the login form, read whether the product has API keys, service principals, or OAuth for automation.

Default to read-only scopes

Separate write tools behind a second approval or a different agent identity.

Never train on OTP fields

Browser agents should refuse to type verification codes; humans supply them when unavoidable.

Audit issuance and use

Map agent id → owner → token family the way OAuth brokers do; see agent OAuth token exchange.

Rotate on role change

When a human leaves or an agent is retired, revoke its token family without re-sharing passwords.

Empyre behaviour (verified 2026-11-12)

Browser automation. Empyre classifies password and one-time verification fields as human-only when an agent controls a browser; security-sensitive clicks, including wording about enabling or disabling two-factor authentication, can require approval rather than running unattended.

Human sign-in. The founder dashboard supports TOTP multi-factor authentication for people signing into Empyre itself, that challenge is not a pattern for unattended agents logging into arbitrary third-party sites.

Destructive account actions. Permanently deleting an Empyre account requires a recent interactive sign-in, including TOTP when enrolled, a human re-auth gate, not an agent API key.

Relay and Vault remain the right products for delegated API access and signing without exporting seeds, see post 24 and Relay / Vault.

Common questions

Can an agent use read-only API access on a 2FA-protected account?

Yes, if the vendor issues a machine token or OAuth scope that does not require per-request TOTP. The 2FA applies to human login, not to well-scoped automation credentials.

Is it safe to store TOTP in HashiCorp Vault for RPA?

Only with strict policy: the agent never reads the seed, humans approve each session, and codes are not logged. Most teams should use machine credentials instead.

Does this replace the OAuth article?

No. Read post 24 for token exchange; read this page when MFA blocks unattended browser login.

Try Starter free for 3 days

Describe a business in plain words and watch eight AI agents build and deploy it. Starter is free for the first 3 days; a card starts the trial.

Start your free trial

Related

Last updated 2026-11-21. Competitor descriptions reflect each product's publicly documented capabilities at that date; they change often, so check the source before relying on a detail.