Login with agent: how AI agents sign in safely
Published
Signing an AI agent in is a different problem from creating a new agent account. When builders look for login with agent or AI agent login, they are usually trying to solve one of two distinct jobs. The first is giving an agent delegated access to an account a human already owns without handing over a password or browser cookie. The second is letting an agent re-authenticate to an account it already created across new sessions, ephemeral containers, or fresh devices -- often called sign in with agent or agent re-login.
Mixing those two jobs leads to fragile workarounds. Scoped OAuth 2.1 handles delegated access into a human's existing account, while brokered re-login through endpoints.agent_login in the Agent Identity Protocol handles ongoing sessions for agent-created accounts. Both keep raw passwords out of prompts and keep the agent authentication boundary explicit.
Why password managers, browser profiles, and shared cookies fail
The fastest shortcut is pasting a password, exporting a browser profile, or copying a session cookie into an agent's environment. As explained in why you should not give an AI agent your password manager, that shortcut breaks down on four operational fronts:
- Unscoped blast radius. A password or browser cookie jar carries every permission the human holds: billing settings, team invites, API key deletion, and unrelated tabs signed in under the same browser profile.
- Zero per-agent audit trail. When a request arrives with a human session cookie or shared login, the service cannot tell whether the human clicked a button or one of three background agents ran a tool call.
- Prompt-injection exposure. Agents read untrusted web pages, issues, and inbound emails. Any cookie, TOTP seed, or password held in the agent's runtime can be read or exfiltrated if a prompt injection redirects the agent's next request.
- Rotation breaks everything else. Rotating one leaked password or revoking a browser session forces the human and every other tool sharing that login to re-authenticate at once.
Scoped OAuth 2.1 delegation for existing human accounts
When an agent needs to act inside an account a person already owns, the right mechanism is scoped OAuth 2.1 delegation rather than shared credentials. Across Model Context Protocol (MCP) clients and servers, OAuth 2.1 gives each coding tool or agent harness its own token, bound to narrow scopes and revocable without touching the human's password.
Three pieces make MCP OAuth work cleanly across local and remote tools. First, Proof Key for Code Exchange (PKCE) with S256 binds the authorization code to the client that started the flow, blocking code interception on loopback redirects or shared hosts. Second, Dynamic Client Registration (DCR) and Client ID Metadata Documents (CIMD) let an MCP client present or register its client identity automatically so the human does not copy client secrets by hand.
Third, consent binds a specific agent identity. During Agent Registrar's OAuth consent step at /oauth/authorize, the human owner selects an active agent sub-identity or creates a new one and approves the exact requested scopes. The resulting OAuth token is tied to that single agent record rather than granting blanket access across every agent the human runs. If one coding tool misbehaves, revoking its OAuth grant or flipping that agent's kill switch stops its access while leaving other agents and the human's login untouched.
How brokered agent re-login solves "Sign in with Agent"
OAuth assumes an existing human account at the target app. Once an agent creates its own account through agentic signup, a second login problem appears: how does that agent sign back in when its local session expires, when a container restarts, or when the human switches to a new machine? Re-running signup risks creating duplicate accounts or colliding on email addresses.
Agent Identity Protocol v2.2.0 and v2.3.0 address this with an optional endpoints.agent_login URL in the service's discovery document (/.well-known/agent-signup.json). The flow separates initial account creation from ongoing agent re-login without turning the broker into a password vault.
Short-lived login assertions via identity_login
Agent Registrar's remote MCP server at https://agentregistrar.dev/mcp exposes 5 tools, documented in the MCP tools reference. When a service publishes endpoints.agent_login, the agent calls identity_login instead of identity_signup. The broker checks that the human owner and agent are active, fetches discovery, verifies any provider verification credential under the human's trust policy, and mints a fresh, uncached 120-second assertion JWT with purpose: "login".
The tool returns a prepared POST request containing that assertion in the Authorization: Bearer header. The agent sends the request directly to the provider's endpoints.agent_login endpoint; the broker is not in the provider's session traffic.
Anti-account-takeover resolution and per-service controls
A login endpoint must not let an unverified claim attach to a human user's account by guessing an email address. Under the protocol's anti-account-takeover resolution rules, providers match a purpose: "login" assertion against an existing agent-linked account (bound to the verified broker issuer and agent subject) rather than merging blindly onto an existing human account by email alone. Providers also enforce single-use jti replay checks so an intercepted login assertion cannot be replayed during its 120-second lifetime.
Human owners keep per-service control over agent re-login in /trust, where they can disable re-login for a specific service while keeping other services enabled. When an agent starts a login session for a new context, the broker also sends a first-session security alert email to the human owner so unexpected re-logins are visible immediately.
Terms re-attestation, handoff, and human step-up
Long-lived agent accounts eventually run into updated terms of service. As covered in how AI agents accept terms of service, each acceptance is pinned to a SHA-256 hash and version string. When a provider bumps terms.version or changes terms.url in discovery, identity_login detects the drift and fetches and hashes the new document before minting the login assertion.
By default, the agent re-accepts updated terms autonomously under the human owner's delegation agreement and records a new acceptance entry linked to the prior one, emailing a copy to the human. If the owner prefers explicit review before accepting new terms, they can turn on human approval in /settings. When terms drift under that setting, identity_login pauses without minting an assertion, emails the owner, and returns an approval URL at /approvals/[id] so the human can review the version change before the agent retries.
On the provider response side, the protocol defines structured replies for both automated and gated logins. On success, the provider can return a handoff object with the new session token or MCP configuration, which the agent saves locally without forwarding secrets back to the broker. When the provider needs an interactive check -- such as linking an existing human workspace or completing additional verification -- it returns human_action_required with a verification_url so the agent stops retrying and directs the human to finish the step.
You can exercise this full login, terms-bump, handoff, and human_action_required sequence end to end in the isolated Demo Network at agentregistrardemobroker.com against the reference provider.
Comparing AI agent login patterns
Each login pattern trades scope, credential custody, and auditability differently depending on whether the account belongs to a human or an agent.
| Approach | Mechanism | Scope & isolation | Credential custody | Terms / session audit trail | Best fit |
|---|---|---|---|---|---|
| Password / cookie sharing | Human pastes password, TOTP secret, or browser cookie into agent runtime. | None; inherits full human account and shared browser session access. | Human credentials live inside agent memory, logs, and disk. | Indistinguishable from human activity; no per-agent session record. | Legacy human-only sites where no API or delegation flow exists. |
| OAuth 2.1 delegation | PKCE + DCR or CIMD consent flow binds scoped token to a specific agent. | Scoped to approved permissions and bound to one agent record. | Client holds OAuth bearer/refresh tokens; password stays with human. | Consent grant and per-agent token issuance logged at authorization server. | Giving an agent controlled access to an existing human account or MCP server. |
Brokered agent login (endpoints.agent_login) | identity_login mints a 120-second purpose: "login" assertion sent directly to provider. | Audience-locked per service, anti-ATO account resolution, and /trust re-login toggle. | Provider issues session via handoff; broker stores zero provider keys. | Logs login assertions, first-session alerts, and SHA-256 terms re-acceptances. | Ongoing re-authentication for agent-created accounts across sessions and devices. |
Honest limits of brokered login
Knowing what the broker does not do is as important as knowing the wire flow. Full protocol boundaries are documented in Trust and limits and Credentials and recovery:
- No credential custody or recovery. The broker never receives, stores, or proxies provider session tokens or API keys returned in
handoff. If an agent loses a local secret, the broker cannot recover it; the agent must re-authenticate throughendpoints.agent_loginif the provider supports it, or follow the provider's own recovery flow. - Kill switch scope. Flipping an agent's kill switch in the Developer Portal stops new
identity_signupandidentity_loginassertions and cuts off inbox access. Existing provider sessions remain governed by the provider's own token expiry and session revocation controls. - Email verification, not KYC. The
human.verifiedclaim proves the human owner verified an email address and signed the delegation agreement. It is not KYC, and providers keep full authority to apply risk scoring, rate limits, orhuman_action_requiredstep-up checks before issuing a session.
Related topics
- How AI agents create accounts on websites
How AI agents create accounts on third-party websites without browser hacks or shared passwords, using brokered signup over MCP and a per-agent inbox.
- Agent authentication: API keys, OAuth, and tokens
How AI agent authentication works across static API keys, OAuth 2.1, SPIFFE workload credentials, and short-lived brokered signup and login tokens.
- How do I let agents sign up for my product?
Agentic signup for your SaaS: how to let AI agents create accounts under a verified human owner, with a signed identity token and recorded terms.
- How do I let an agent sign my terms of service?
How AI agents can accept your terms of service (ToS) under a verified human owner, with the exact version recorded and a copy emailed to the human.