Skip to main content

Mediated Sign-In

Mediated Sign-In is an extension of version 0.4, version 1, for companies that can't offer Direct or Device Sign-In yet. The company lists it in extensions in its poppy.json, with the fields it needs and the scopes it can grant, and lists the grant type https://personalagentprotocol.org/grant/mediated-sign-in in its issuer's grant_types_supported. The personal agent sends what the user types to the issuer's token endpoint: it is an OAuth extension grant (RFC 6749 ยง4.5), and the one sign-in where a password passes through the agent's host, so prefer Direct Sign-In, then Device Sign-In, when the company offers them.

{
"extensions": {
"mediated-sign-in": [
{
"version": "1",
"fields": [
{ "name": "email", "label": "Email", "secret": false },
{ "name": "password", "label": "Password", "secret": true }
],
"scopes": ["orders:read"]
}
]
}
}

The personal agent doesn't declare the extension in Poppy-Extensions, which the token endpoint doesn't receive: the company recognizes it from the grant type, and can't answer it with extension_required. mediated_sign_in(company) reads what a discovered company offers, or None.

Mediated Sign-In is transitional

Like OAuth's password grant, which OAuth 2.1 removes, Mediated Sign-In is a step on the way, not where the protocol is headed. A company should offer it only until it can add Direct or Device Sign-In, and stop once those cover the scopes it grants. The protocol plans to retire it on March 17, 2027 (MEDIATED_RETIREMENT_DATE), as version 1.0 says.

Protected inputโ€‹

The values are collected through the Reactor pap.protectedInput contribution (ProtectedInputs in TypeScript): the host's own trusted surface, such as a native password field or a secure form outside the chat. They never come from a model, a tool argument, or conversation text.

from personal_agent_protocol import PROTECTED_INPUTS, ProtectedInputRequest

class PasswordSheet:
async def collect(self, request: ProtectedInputRequest) -> dict[str, SecretStr]:
# request.purpose: "credentials" or "one_time_code"
# request.company_name / company_domain: show who is asking
# request.fields: name, label, secret (mask secret fields)
# request.sent_to: where the company sent a code, as it masked it
return await native_secure_form(request)

The answers must be exactly the declared fields, none empty, as SecretStr.

Signing inโ€‹

client = MediatedSignInClient(reactor=reactor, http_client=http)
result = await client.sign_in(
company=company, client_id=client_id, scopes=("orders:read",), tenant_id="tenant-one"
)
if result.status == "code_required":
result = await client.submit_code(result.reference)
const client = new MediatedSignInClient({ reactor, fetch });
let result = await client.signIn({ company, clientId, scopes, tenantId: 'tenant-one' });
if (result.status === 'code_required') {
result = await client.submitCode(result.reference!);
}

What the client enforcesโ€‹

  • One endpoint. The values go to the token_endpoint of the company's issuer, with this grant and a client assertion, and nowhere else. Redirects are refused, never followed, so a credential cannot be carried to another URL.
  • Field names checked. A field named like a parameter of the grant, such as client_id, scope, resource or sign_in_id, is invalid_mediated_extension, raised before the user is asked anything.
  • Sent once, then dropped. The values are put into one token request and cleared; no result, error, or log carries them.
  • A code continues alone. code_required (HTTP 400, with sign_in_id, sent_to and expires_in) stores an opaque reference in the pap.authorizationStateStore. The continuation sends the same grant with sign_in_id and one_time_code, and neither the credentials nor scope: the sign-in keeps the scopes of the first request, and only the client_id that started it can finish it. A wrong code returns code_required again until the company's limit.
  • OAuth errors. invalid_grant (a wrong password, too many wrong codes, an unknown sign_in_id), expired_token, access_denied and invalid_scope are raised as AuthorizationError. A rate limit is HTTP 429 with Retry-After: rate_limited, with retry_after, keeps a pending code.
  • No escalation. A completed sign-in is the same token response as Direct and Device Sign-In, with no scope that was not requested. The refresh token goes to the token store; only its reference is returned.

For a companyโ€‹

CompanyConfig(mediated_fields=(...), mediated_scopes=(...)) publishes the extension and lists the grant. A reserved field name is refused when the configuration is built, attempts are limited by account and by client_id, an unknown account and a wrong password both answer invalid_grant, and an AccountDirectory raises SignInRefused to answer access_denied.

Security boundaryโ€‹

The model may say that sign-in needs the user's credentials and where the code was sent. It must never ask for a password or code in chat. If a user pastes one into the conversation anyway, the host should not forward it.

See the runnable Mediated Sign-In example and the upstream Mediated Sign-In extension.