Skip to main content

Private key JWT for agents

A Private key JWT agent proves who it is with a client assertion: a short JWT that the agent signs with its private key whenever it asks for a token. LumoAuth stores only the public key. Nothing secret is stored on the server or sent over the network, so there is no secret to leak from a log or a configuration file. The format is the standard private_key_jwt client authentication of OAuth (RFC 7523 with the audience rules of RFC 10070, and OpenID Connect Core §9), so any OAuth library that supports it works.

When to choose it​

Pick the identity type in this order:

  1. Workload identity when the agent runs on a platform that issues tokens: GitHub Actions, GitLab CI, Kubernetes, AWS EKS, Google Cloud, Azure, SPIFFE or another OIDC issuer.
  2. Private key JWT when the platform issues no tokens but the agent can keep a private key: a virtual machine, an on-premises host, AWS Lambda or EC2, or a desktop app. Keep the key in a secrets manager, a KMS or an HSM.
  3. AAuth when every request that the agent sends must be signed, not only the token request.

Compared with a client secret, the private key never leaves the agent. It works over plain HTTPS, through any proxy or CDN, and needs no certificate setup.

Register the agent​

In the portal​

  1. Open AI Agents → Agents and click Register agent.
  2. On step 2, How it proves its identity, choose Private key JWT.
  3. Give the agent's public keys in one of two ways:
    • JWKS URL: an https address where the agent publishes its public keys. This is the easiest to rotate.
    • Public keys (JWKS): paste the key set, {"keys": [...]}.
  4. Finish the wizard. No secret is generated. The agent's page opens, and its Next steps section has a Python example that signs an assertion and requests a token.

With the Admin API​

POST /orgs/acme-corp/api/v1/admin/agents
Content-Type: application/json

{
"name": "Invoice agent",
"identityType": "private_key_jwt",
"jwksUri": "https://agent.example.com/.well-known/jwks.json",
"capabilities": ["invoices:read"]
}

Send jwks (the key set as a JSON object) instead of jwksUri to register the keys inline. Give exactly one of the two. The response, and GET /admin/agents/{agentId}, include jwksUri, jwks and keyThumbprints (the RFC 7638 thumbprint of each inline key).

Create a key pair​

Any tool that writes a PEM key works. For an EC P-256 key:

openssl genpkey -algorithm EC -pkeyopt ec_paramgen_curve:P-256 -out agent-private-key.pem

This Python script prints the public key as a JWKS that you can paste into the portal:

# pip install "pyjwt[crypto]"
import json
import jwt
from cryptography.hazmat.primitives import serialization

with open("agent-private-key.pem", "rb") as f:
private_key = serialization.load_pem_private_key(f.read(), password=None)

jwk = json.loads(jwt.algorithms.ECAlgorithm.to_jwk(private_key.public_key()))
jwk["kid"] = "agent-2026-11"
print(json.dumps({"keys": [jwk]}))

Key requirements​

Key typeCurve or sizeAlgorithms
ECP-256ES256
ECP-384ES384
ECP-521ES512
OKPEd25519EdDSA
RSA2048 bits or moreRS256, RS384, RS512, PS256, PS384, PS512
  • A key set holds 1 to 10 keys. Each key needs a kid when the set holds more than one.
  • Symmetric keys and other curves (such as secp256k1) are not accepted.
  • A key with alg may sign only with that algorithm. A key with use must say sig.
  • Only public keys are accepted. A key set that contains private key material (d, p, q and so on) is refused as a whole, so a pasted private key is never stored.

A JWKS URL must be an absolute https URL on a public address, with no user info and no fragment. LumoAuth reads it with a 10-second timeout and a 256 KiB limit, and does not follow redirects. It caches the document for 15 minutes. A failed read is never cached. When an assertion names a kid that the cached document lacks, LumoAuth reads the URL again, at most once a minute for each agent.

Build the client assertion​

Sign a new assertion for every request. Each one is single-use.

Header

MemberValue
algOne of the algorithms in the table above, matching the key
kidThe key's kid. Required when the agent has more than one key
typclient-authentication+jwt (recommended, also accepted as application/client-authentication+jwt) or JWT; may be left out

A header with crit is refused.

Claims

ClaimValue
issThe agent ID, for example agt_0123456789abcdef
subThe agent ID, the same as iss
audThe organization's issuer identifier: the issuer value of /orgs/{orgId}/api/v1/.well-known/openid-configuration, for example https://app.lumoauth.dev/orgs/acme-corp/api/v1
expExpiry time, at most 10 minutes from now. One minute is a good choice
jtiA unique value of 16 to 255 characters, such as a random UUID
iat, nbfOptional
The audience is the issuer, not the token endpoint

aud must be the issuer identifier and nothing else: one string, or a list with only that value. An assertion whose audience is the URL of the token endpoint, or that also names another server, is refused. This follows the current OAuth rules for client assertions and prevents a server from replaying an assertion that was made for it at another server.

The value is compared byte for byte, so a trailing slash or a change of case is refused. The issuer form without /api/v1, from before September 2026, is refused too.

LumoAuth allows 60 seconds of clock difference for exp, nbf and iat.

Request a token​

Use the client credentials grant and send the assertion instead of a secret:

POST /orgs/acme-corp/api/v1/oauth/token
Content-Type: application/x-www-form-urlencoded

grant_type=client_credentials
&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer
&client_assertion=eyJhbGciOiJFUzI1NiIsImtpZCI6ImFnZW50LTIwMjYtMTEiLCJ0eXAiOiJjbGllbnQtYXV0aGVudGljYXRpb24rand0In0...
  • client_id is optional. If you send it, it must be the agent ID.
  • Do not send a client_secret as well: a request may use one authentication method only.
  • scope is optional and can only narrow the agent's capabilities. resource may name one MCP server.
  • Write each scope value as <resource>:<action>, such as invoices:read. A value with a . gets 400 invalid_scope. A request with resource uses the scope strings of that MCP server instead.
  • Add a DPoP header to get a token bound to a key that the agent holds ("token_type": "DPoP"). Turn on Only issue DPoP-bound tokens on the agent to make that mandatory.

The response is the same as for any agent token: an access_token that expires after at most an hour (an MCP server can set a shorter lifetime).

Python​

# pip install "pyjwt[crypto]" requests
import time, uuid
import jwt, requests

AGENT_ID = "agt_0123456789abcdef"
ISSUER = "https://app.lumoauth.dev/orgs/acme-corp/api/v1"
TOKEN_URL = ISSUER + "/oauth/token"

with open("agent-private-key.pem") as f:
private_key = f.read()

now = int(time.time())
assertion = jwt.encode(
{"iss": AGENT_ID, "sub": AGENT_ID, "aud": ISSUER,
"iat": now, "exp": now + 60, "jti": str(uuid.uuid4())},
private_key,
algorithm="ES256",
headers={"kid": "agent-2026-11", "typ": "client-authentication+jwt"},
)

response = requests.post(TOKEN_URL, data={
"grant_type": "client_credentials",
"client_assertion_type": "urn:ietf:params:oauth:client-assertion-type:jwt-bearer",
"client_assertion": assertion,
})
response.raise_for_status()
access_token = response.json()["access_token"]

Node.js​

// npm install jose
import { SignJWT, importPKCS8 } from 'jose';
import { readFile } from 'node:fs/promises';
import { randomUUID } from 'node:crypto';

const AGENT_ID = 'agt_0123456789abcdef';
const ISSUER = 'https://app.lumoauth.dev/orgs/acme-corp/api/v1';

const key = await importPKCS8(await readFile('agent-private-key.pem', 'utf8'), 'ES256');
const assertion = await new SignJWT({})
.setProtectedHeader({ alg: 'ES256', kid: 'agent-2026-11', typ: 'client-authentication+jwt' })
.setIssuer(AGENT_ID)
.setSubject(AGENT_ID)
.setAudience(ISSUER)
.setIssuedAt()
.setExpirationTime('60s')
.setJti(randomUUID())
.sign(key);

const response = await fetch(`${ISSUER}/oauth/token`, {
method: 'POST',
body: new URLSearchParams({
grant_type: 'client_credentials',
client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
client_assertion: assertion,
}),
});
const { access_token } = await response.json();

openssl genpkey writes a PKCS #8 key, which importPKCS8 reads.

Go​

// go get github.com/golang-jwt/jwt/v5 github.com/google/uuid
claims := jwt.RegisteredClaims{
Issuer: agentID,
Subject: agentID,
Audience: jwt.ClaimStrings{issuer},
IssuedAt: jwt.NewNumericDate(time.Now()),
ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Minute)),
ID: uuid.NewString(),
}
token := jwt.NewWithClaims(jwt.SigningMethodES256, claims)
token.Header["kid"] = "agent-2026-11"
token.Header["typ"] = "client-authentication+jwt"
assertion, err := token.SignedString(privateKey) // *ecdsa.PrivateKey from jwt.ParseECPrivateKeyFromPEM
if err != nil {
return err
}

form := url.Values{
"grant_type": {"client_credentials"},
"client_assertion_type": {"urn:ietf:params:oauth:client-assertion-type:jwt-bearer"},
"client_assertion": {assertion},
}
resp, err := http.PostForm(issuer+"/oauth/token", form)

The Go library writes aud as a list with one value, which LumoAuth accepts.

Introspect a token​

The agent authenticates to POST /orgs/{orgId}/api/v1/oauth/introspect the same way: send token plus a new client_assertion_type and client_assertion. The agent must be active.

Rotate keys​

Rotate without downtime by keeping the old and the new key side by side for a while.

With a JWKS URL

  1. Publish the new public key in the document next to the old one, with a new kid.
  2. Switch the agent to sign with the new key. The first assertion with the new kid makes LumoAuth read the URL again, so the new key works right away.
  3. Remove the old key from the document.

LumoAuth cannot see when a key disappears from a URL, so tokens obtained with the old key stay valid until they expire (at most an hour). If a key was compromised, also suspend the agent (Suspend in its actions menu on the Agents page, or POST /admin/agents/{agentId}/disable), which runs the kill switch.

With inline keys

  1. Edit the agent and add the new key to the key set, with its own kid. In the Admin API, send the whole new set in jwks with PATCH /orgs/{orgId}/api/v1/admin/agents/{agentId}.
  2. Switch the agent to sign with the new key.
  3. Remove the old key from the set.

Removing a key from the set, or switching between a JWKS URL and inline keys, revokes the access tokens that the agent holds. The agent then signs a new assertion with its current key. Adding a key revokes nothing.

Changing an agent's keys gives the agent to whoever holds the new private key, so it needs every capability that the agent has. Each change is audited: agent.updated lists the old and new key thumbprints or JWKS URL, and a change in the portal also writes agent.identity_rebound.

Errors​

Every refused assertion returns 401 with "error": "invalid_client", whatever the cause. The reason goes to the audit log as agent.client_assertion_rejected:

ReasonMeaning
unsupported_assertion_typeclient_assertion_type is not urn:ietf:params:oauth:client-assertion-type:jwt-bearer
missing_assertionNo client_assertion, or longer than 8 KiB
malformedNot a JWT in compact form, or its parts cannot be read
unsupported_algalg is not in the table above (for example none or HS256)
wrong_typtyp is set to something other than client-authentication+jwt or JWT
unsupported_critThe header has crit
no_keys_registeredThe agent has no public keys yet
keys_unavailableThe JWKS URL could not be read, or its document was refused
kid_requiredThe agent has several keys and the header has no kid
unknown_kidNo key has this kid and fits alg, even after reading the URL again
no_matching_keyThe agent's only key does not fit alg
bad_signatureThe signature does not verify with the key
expired, not_yet_validexp has passed, or nbf or iat is in the future
iss_sub_mismatchiss or sub is not the agent ID
wrong_audienceaud is not the issuer identifier alone
missing_exp, lifetime_too_longexp is missing, or more than 10 minutes ahead
bad_jtijti is missing, or shorter than 16 or longer than 255 characters
replayedThe agent already used this jti

Security notes​

  • Each jti is accepted once per agent, on every LumoAuth server. If that check cannot run, the assertion is refused.
  • The agent's security posture is critical while it has no public key, and the agent cannot sign in until one is added.
  • An access token is a bearer token unless you add DPoP. Assertions protect the token request; DPoP protects each request made with the token.
  • The identity type is fixed after registration. To move an agent from a client secret to a private key JWT, register a new agent with the same capabilities, switch the workload over and revoke the old agent.