Identity & Token Protocol
The implementation-independent contract. Generated from the canonical spec
protocols/specs/machine-identity.md as of 2026-11-21 (84a386d). Implemented by
ChirpAuth.
Changing (decided 2026-11-15, not yet built): a machine token will be minted for one named
audience, withsubandowner_subpairwise to that relying party and noazpor client id, and Granite will key a machine by its root. The token shape, verification and Granite sections below describe today's shape until then. Seedocs/adr-one-machine-name.md(agent-platform--protocols#115).
This spec extends ChirpAuth to issue identities for non-human actors — agents and other machine clients — so that third parties can register and run agents that participate in the platform.
Purpose
Today ChirpAuth issues ID tokens only for humans (Authorization Code + PKCE
with email-link or passkey login). This spec adds machine tokens so that every
agent — platform-hosted and external alike — is identified by a single ChirpAuth
machine sub (agent_…). There is no separate Drive-resource / agent_id identity
space for hosted agents; they are ChirpMachines like any other.
It does not work for external agent providers — a third party who wants to run their own agent runner and participate in Pigeon, Drive, Granite, and Model Gateway as a recognized actor. They need a portable, verifiable identity that isn't bound to any single service's internal id space.
This spec adds confidential clients and the OAuth2 client_credentials grant
to ChirpAuth. The same JWKS signs both human and machine tokens; consuming
services use claim shape to distinguish them and decide whether to accept.
Goals
- A third-party developer can register an agent identity with one CLI command.
- Their external runner mints short-lived ID tokens by presenting a client
secret to
POST /token. - Any consuming service (Pigeon, Drive, Granite, Model Gateway) verifies the
token with the existing
chirp-auth-clientcrate. - Granite grants can name a machine identity as their subject; verification flows stay the same.
- Every machine identity is tied to a legally responsible human owner whose audit trail leads back through the owner's chirp-sub.
Non-Goals
- Retaining a separate hosted-agent (
agent_id, Drive-keyed) identity space — removed; all agents are ChirpMachines identified by their ChirpAuth sub. - A web console for external providers. Registration is CLI-only in MVP.
- Permission scopes embedded in the token. Scope lives at the consuming service via Granite; ChirpAuth issues identity only.
- Refresh tokens for machine clients. The client secret IS the long-term
credential; tokens are re-minted via
client_credentialsas needed. - Real-time token revocation. Worst-case grace is one token lifetime (~1 hour) after the owner or client is suspended.
Core Concepts
| Term | Meaning |
|---|---|
| Public client | Existing: a browser-based app using Authorization Code + PKCE. No secret. Token shape includes email claim. |
| Confidential client | New: a server-side machine actor with a client_secret. Uses client_credentials grant. Token shape includes act: "machine" and owner_sub. |
| Owner | The human chirp-sub responsible for a confidential client. Stored on the client record. Required at registration time. |
| Machine token | ID token issued via client_credentials. Same JWKS as human tokens; different claim shape. |
| Human token | Existing ID token issued via Authorization Code + PKCE. |
Token Shapes
Both token kinds are JWTs signed by the same rotating JWKS, with the same
iss and kid. They differ in payload claims:
Human token (existing, unchanged)
{
"iss": "https://signin.example.com",
"sub": "sub_<random>",
"aud": "cs_live_<client_id>",
"exp": 1747680000,
"iat": 1747676400,
"nonce": "nonce_...",
"email": "user@example.com",
"email_verified": true
}
Machine token (new)
{
"iss": "https://signin.example.com",
"sub": "agent_<random>",
"aud": "cs_live_<client_id>",
"azp": "cs_live_<client_id>",
"act": "machine",
"owner_sub": "sub_<random>",
"exp": 1747680000,
"iat": 1747676400
}
Distinguishing rules:
actclaim presence indicates a machine token. Absence indicates a human token. Consuming services useactas the dispatch key.subprefix is informational only:sub_*for humans,agent_*for machines. Verification must NOT rely on prefix alone; theactclaim is authoritative.- Machine tokens carry no
email, noemail_verified, nononce. azp(authorized party) is the client id, included for OIDC compliance when only one audience is present.
Registration
The developer first authenticates as themselves (Authorization Code + PKCE).
The CLI captures their human chirp-sub and uses it as owner_sub for any
clients they then create.
$ chirp-auth login
Opens browser to sign in...
Signed in as alice@example.com (sub_abc...).
$ chirp-auth app create --type confidential --name "acme-summarizer"
Creating confidential client owned by sub_abc...
client_id = cs_live_<random>
client_secret = <random_secret_shown_once_never_again>
owner_sub = sub_abc...
The secret is hashed at rest. It cannot be retrieved later. The developer must store it themselves (env var, secrets manager, etc.). If lost, the client must be deleted and re-created.
A chirp-auth.toml for confidential clients omits redirect URIs (none are
needed) and includes a type = "confidential" field. The secret is NEVER
written to the toml; only the public client_id, owner_sub, name, and
type are stored.
Token Issuance
POST /token accepts a new grant:
POST /token HTTP/1.1
Authorization: Basic base64(client_id:client_secret)
Content-Type: application/x-www-form-urlencoded
grant_type=client_credentials
Alternative form: client_id and client_secret in the POST body. Either
works.
Success response:
{
"token_type": "Bearer",
"expires_in": 3600,
"id_token": "eyJ...<machine_token>"
}
No access token, no refresh token. The ID token is the bearer credential consuming services verify directly.
Failure modes (RFC 6749 compliant):
invalid_client— wrong client_id or secretunauthorized_client— client is not confidential type, or owner is suspendedunsupported_grant_type— client_credentials not requested
Verification
The chirp-auth-client crate exposes a single verify_chirp_id_token
function that handles both token shapes. Callers indicate which kinds they
accept via VerifyOptions:
pub struct VerifyOptions {
pub require_email: bool, // existing
pub accept_machine: bool, // new, default false
}
pub enum ChirpVerifiedIdentity {
Human {
sub: String,
email: Option<String>,
name: Option<String>,
},
Machine {
sub: String,
owner_sub: String,
client_id: String,
},
}
Default VerifyOptions accepts only human tokens. Services that want machine
identities opt in. The change is additive: all current callers compile and
behave as today.
Verification semantics:
- Standard JWT verification (signature,
iss,aud,exp,nbf,alg). - If
act: "machine"is present andoptions.accept_machine == false, the token is rejected withChirpAuthError::MachineNotAllowed. - If
act: "machine"is absent andoptions.require_email == true, the human token must carryemail; absent →EmailRequired. - Machine tokens with
act: "machine"but missingowner_subare rejected as malformed.
Per-Service Acceptance
| Service | Accepts machine tokens | Reason |
|---|---|---|
| personal-ecosystem (Social Graph) | No | Photo gallery is human-only. Default VerifyOptions. |
| Drive | Yes | Maps to existing DriveActor::AgentRun. Granite-grant verification already in place. |
| Pigeon | Yes | Adds Actor::AgentRun { sub, owner_sub }. Mutations require Granite grant naming sub. |
| Granite | Yes | Machine clients call /v1/grants/verify and read grant state. |
| Model Gateway | Yes | External providers spend against grants the same way hosted agents do. |
Services that accept machine tokens must verify a Granite grant before performing any mutation on the owner's behalf. The token establishes identity; the grant establishes authorization. ChirpAuth never sees the grant; Granite never sees the secret.
Granite Integration
Granite grants name their subject by subject_chirp_sub — the agent's ChirpAuth
machine sub (agent_…). Every agent, hosted or external, is a ChirpMachine
identified by its ChirpAuth sub; there is no separate agent_id / Drive-resource
identity space. (The old subject_agent_id / requester_agent_id fields were
removed; a machine identity is a single chirp_sub, not one of two rails.)
The verify endpoint takes the subject as subject_chirp_sub:
POST /v1/grants/verify
{
"grant_id": "grant_...",
"subject_chirp_sub": "agent_..."
}
Revocation Semantics
ChirpAuth does not maintain a real-time token blacklist. When a confidential client or its owner is suspended:
- New
client_credentialsrequests immediately returnunauthorized_client. - Already-issued tokens remain valid until their
exp(≤ 1 hour).
This trades real-time precision for stateless verification. Consuming services do not need to call back to ChirpAuth on every request.
Operators who need immediate revocation can rotate the JWKS signing key — this invalidates ALL outstanding tokens (machine and human). It is a blunt instrument; reserve for actual key compromise.
Security Invariants
- Client secrets are stored hashed at rest. The plaintext is shown to the caller exactly once at creation time.
- Confidential client registration requires an authenticated human session.
The session's chirp-sub is captured as
owner_suband stored on the client. There is no way to register a client without an owner. - Machine tokens never include
emailor any other human-only claim. - The
act: "machine"claim is set server-side at issuance and is cryptographically bound by the JWT signature. Consuming services trust it as authoritative. - Suspension of a human owner blocks new token issuance for all their clients. Existing tokens grace out within one lifetime.
- Per-owner client count and per-client token-issuance rate are subject to
rate limits matching the existing
/tokenendpoint limits.
Out of Scope
- Per-client scope claims embedded in the token.
- Real-time token revocation (blacklist).
- Refresh tokens for machine clients.
- Web console for external providers; CLI is the only registration surface.
- Tiered owner accountability (e.g., individual vs. organization). All owners are treated identically.
Open Product Questions (not engineering)
- Legal click-through at confidential client creation acknowledging responsibility for the agent's actions. Product/legal copy decision.
- Per-owner quota: how many confidential clients may a single human own. Defer until needed.
- Pricing and rate-limit tiers for external providers.
Acceptance Criteria
The spec is implemented when:
- A new confidential client can be registered with one CLI command after signing in as a human.
POST /tokenwithgrant_type=client_credentialsreturns a machine ID token whose claims match this spec.- The
chirp-auth-clientcrate verifies machine tokens behind an opt-inaccept_machineflag without breaking any existing human-only caller. - A Granite grant naming
subject_chirp_sub: agent_...can be verified. - An external agent can register, mint a token, receive a user grant, and answer that user over ChirpMail (Pigeon carries no messages since pigeon#162) — all in an end-to-end integration test.
sign-in-service-spec.mdis updated to remove the "confidential clients deferred" line and reference this spec.