Skip to content

How an AI Agent Gets Access on a User’s Behalf

How an AI Agent Gets Access on a User's Behalf

A finance director asks an AI agent to have last quarter’s revenue by region ready for a 9 a.m. board call. The agent runs the queries at 2:40 a.m. on the director’s own token, so the audit log shows the director reading revenue tables while they slept, and nothing in it tells their clicks apart from the agent’s calls. That token would have approved a payment just as readily.

On-behalf-of access for AI agents is a form of delegated authorization in which an agent exercises a person’s authority while staying identifiable as itself. Its token names both: the user whose permissions apply and the agent doing the work.

OAuth token exchange, defined in RFC 8693, standardizes that naming and repairs the log. It leaves two problems open in every on-behalf-of design: nothing yet caps the agent below the user’s full authority, and the agent’s token is one more credential that can leak. Solve attribution alone and the payment stays within reach.

Why Does Forwarding the User’s Token Fail?

Forwarding fails because the user’s token was minted for a different recipient and a broader job. Its aud claim names the app the director signed in to, so a reporting API that checks the audience, as RFC 9700 directs, refuses it. The tempting fix is to switch that check off, after which the API accepts tokens minted for any app the issuer serves.

A token that gets through still carries every scope the director approved, payments included, and the log credits each call to the director. Cutting off the agent ends the director’s session, since both share one credential. The Model Context Protocol (MCP) rules the shortcut out for MCP servers, whose authorization security considerations state that a server “MUST NOT pass through the token it received from the MCP client.”

Impersonation vs. Delegation

A separate token can carry the user’s authority in two ways that differ in whether the agent stays visible. RFC 8693, the Internet Engineering Task Force (IETF) standard for OAuth token exchange, defines both: an impersonating party holds the subject’s rights and cannot be told apart from the user, while a delegate keeps its own identity, a relationship the RFC sums up as “In a sense, A is an agent for B.”

PropertyImpersonationDelegation
Identities in the tokenThe user onlyThe user and the agent
Rights availableAll the user’s rights in that contextWhat the user delegated
What the log showsThe user actingThe agent acting for the user
Blocking only the agentNot possible at the targetDeny the agent’s identity

A consent screen records which application a person approved. It says nothing about which agent inside that application will act or what that agent passes on, and the gap is part of why human identity providers fall short for agents. Delegated authorization closes the gap by writing the agent’s own identity into the token beside the user’s.

How Does OAuth Token Exchange Work?

Getting that token takes one request to the authorization server, carrying the user’s token and the agent’s own, shown without URL encoding:

POST /token HTTP/1.1
Host: auth.example.com
Content-Type: application/x-www-form-urlencoded

grant_type=urn:ietf:params:oauth:grant-type:token-exchange
&subject_token=<the director’s access token>
&subject_token_type=urn:ietf:params:oauth:token-type:access_token
&actor_token=<the agent’s own JWT>
&actor_token_type=urn:ietf:params:oauth:token-type:jwt
&audience=https://reports.example.com
&scope=reports.read

RFC 8693 requires only grant_type, subject_token, and subject_token_type, plus actor_token_type when an actor token is sent. Adding an actor token is how the client asks for delegation (the authorization server’s policy decides whether the issued token reflects it), and it means the agent must first prove who it is, which is where secret zero shows up. The server validates both tokens, checks its policy, and returns the delegated token, decoded here:

{
  "iss": "https://auth.example.com",
  "aud": "https://reports.example.com",
  "sub": "[email protected]",
  "act": { "sub": "agent:revenue-reporter" },
  "scope": "reports.read"
}

The sub claim keeps the director’s permissions in force, and act lets the target’s log name the agent. When one agent hands work to another, the authorization server can nest the earlier actor inside the new one:

{
  "sub": "[email protected]",
  "act": {
    "sub": "agent:report-formatter",
    "act": { "sub": "agent:revenue-reporter" }
  }
}

The outermost act is the current actor. RFC 8693 bases access decisions on it and the top-level claims alone and treats nested actors as informational only. The chain survives only in your logs.

The may_act Claim: Consent Before Delegation

Nothing in that exchange proves the director approved this agent. The may_act claim can record that consent in the user’s own token by naming who may act for its subject:

{
  "sub": "[email protected]",
  "may_act": { "sub": "agent:revenue-reporter" }
}

When that token arrives as the subject_token, the authorization server can compare may_act with the actor token’s subject and treat a mismatch as unacceptable under policy, which RFC 8693 answers with invalid_request. Without the claim, configuration alone decides. The catch is upstream: the user’s token has to carry that approval from the moment it is issued.

Entra’s On-Behalf-of Flow Is Not RFC 8693

If that issuer is Microsoft Entra ID, the grant differs. Microsoft’s documentation specifies grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer, the JSON Web Token (JWT) bearer grant that RFC 7523 defines, with an added requested_token_use=on_behalf_of. The middle-tier app sends the user’s token as the assertion, and there is no actor_token. Entra also checks the audience: the incoming token must name the requesting app, ruling out a token meant for Microsoft Graph, and for Microsoft Entra Agent ID it must name the agent identity blueprint. Entra’s token carries the user in sub and the calling app in azp, or appid in v1.0 tokens.

Before You Build
Confirm which grant your identity provider implements before you write the exchange. The two flows solve the same problem, but the request you send and the token you get back are different.

The Ceiling Rule

Whichever grant issued it, the ceiling rule caps the agent at the intersection of what the user may do and what the agent may do. Naming the agent limits nothing by itself. Without the cap, an agent acting for an administrator with privileged access to production inherits all of it.

The director’s role covers reading revenue reports, approving payments, and changing vendor bank details. The agent’s policy stops at reading reports, so for the director it reads reports, and for an analyst confined to the West region, only West region reports. At the exchange, that means issuing scope=reports.read although the director could approve payments, as RFC 8693’s security considerations suggest for delegated rights. A scope that coarse cannot express “West region only”, so the finer cut falls to the target’s row-level rules for the user in sub. Pair the cap with just-in-time access and the intersection ends with the task, leaving no standing access between tasks.

Where Does the Delegated Token Live?

The delegated token lives wherever the agent’s runtime puts it, and it is the one part of on-behalf-of access for AI agents that can outlast its task. Unless it is sender-constrained, whoever holds it can use it, so four AI agent identity security questions apply:

  • How long does it live? RFC 8693’s examples run from one minute to one hour, and a one-hour token outlives a five-minute task by 55 minutes.
  • Is it written anywhere? A token cached to a file or printed in a debug log works for whoever finds it.
  • Who else can read it? Other agents and tool servers in the same process, plus a prompt injection if the token enters the model’s context.
  • Does revocation reach downstream? A service validating a JWT locally accepts it until expiry, and RFC 8693 treats carrying a revocation from the user’s token to delegated tokens as a deployment choice.

A token brokered per call and never persisted sidesteps most of these risks. That is the model behind Akeyless SecretlessAI: the Akeyless Gateway brokers each connection and creates access on demand, so the agent never holds or sees the credential, and a compromised or prompt-injected agent has nothing to steal.

Delegation still leaves the ceiling and the audit trail to enforce, and that is where Akeyless Agentic Runtime Authority comes in. It evaluates each agent action at the Gateway against the originating prompt and policy, holding the agent to the authority its task needs even when the user it acts for has broader rights, and blocking actions that exceed the assigned task before they execute. Every action lands in one immutable record, from the originating prompt to the final action on the target, that traces back to the person who initiated it, so the audit trail names both parties even when the target system’s own logs record only a service account.

What to Check in Your Own On-Behalf-of Flow

All three problems show up in one token, so start by decoding one that your agent presents downstream. If sub names the agent or a service account, the user has dropped out of the authorization decision. If nothing names the agent, you’re running impersonation and need an exchange that carries an actor token. If act or client_id names the agent but scope matches everything the user holds, issue the intersection instead. If the token outlives the task or sits in a file or log, put a broker in front of it. Take those fixes in order. An exchange can intersect permissions only for an agent it can already identify.

FAQs About On-Behalf-of Access for AI Agents

What does on-behalf-of mean for an AI agent?

On-behalf-of access for AI agents means the agent borrows a person’s authority without borrowing the person’s identity. The token it presents names the person in the sub claim, which the target uses for permissions, and the agent in an act claim, which tells the target’s log which agent made each request.

What is the difference between impersonation and delegation?

Impersonation makes the acting party indistinguishable from the user, so downstream systems see only the user. Delegation keeps the acting party’s identity in the token beside the user’s, so a target can block one agent without blocking the person, and investigators can tell their actions apart.

What is the act claim in a JWT?

The act (actor) claim, defined in RFC 8693, names whoever is acting for the token’s subject right now. Its value is a JSON object of identity claims such as sub, and nested act claims record prior actors. The separate client_id claim names the OAuth client that requested the token.

Does Microsoft Entra’s on-behalf-of flow use RFC 8693?

No. Microsoft Entra ID uses the JWT bearer grant from RFC 7523 with requested_token_use=on_behalf_of, sending the user’s token as the assertion and no actor token. That token must be issued to the requesting app, so clients built for RFC 8693 need changes for Entra.

How do you audit a multi-hop delegation chain?

Record the nested act chain on every request, with the token’s subject, its audience, and the time of the call. RFC 8693 bases authorization on the subject and current actor alone. Prior actors survive only in your records, which is where investigators trace which agent passed work to which.

Related Resources

View all
Illustration of a secretless AI agent using Akeyless runtime authority
Blog How We Put Zero-Secret AI Agents to Work

Summary: Secretless access and runtime authorization are important concepts in AI agent security, but what do they look like in practice? At Akeyless, we…

November 15, 2026
  • G2 Fall 2026 Leader — Non-Human Identity Management
  • G2 Fall 2026 Momentum Leader — Privileged Access Management
  • G2 Fall 2026 High Performer — Certificate Lifecycle Management
  • G2 Fall 2026 Easiest To Do Business With — Secrets Management
  • G2 Fall 2026 Easiest To Use — Privileged Access Management, Enterprise
  • G2 Fall 2026 Best Support — Privileged Access Management, Enterprise