Secrets and signed assertions
A client secret has to travel with every tokenA piece of data issued by a trusted service that a client presents as a credential, for example to call an API or to report a sign-in. Some tokens carry readable claims; others are random strings that only the issuer can interpret. request. A private keyThe half of a key pair that its owner keeps to themselves and uses to create signatures or decrypt data. Anyone who obtains it can act as its owner. never travels at all. Following both through the printer's token request shows what each one costs, what the server checks, and what a captured request is worth.
Living with a client secret
The printer has used a client secret since its first token request. It works, and it is simple. It also means the most valuable thing the printer owns is a string that has to be copied into every server that talks to the photo service, and sent across the network with every token request. The alternative is a private key that the printer keeps and never sends anywhere. Secrets and key pairs introduced the difference between a shared secret and a key pairA private key and a public key generated together and mathematically linked. The private key creates signatures and the public key checks them, but the private key cannot practically be worked out from the public one.; here both go through a token request.
A client secret is a shared secret: the printer has it, and the photo service can check it. The authorization serverIn OAuth, the service that handles a person's sign-in and approval and decides which tokens to issue to a client. It may belong to the same company as the API, but its job is separate. should generate it, not the developer, so that it is long and random rather than a memorable word. Many services show it once, when it is created, and never again.
On the server side, a secret used with client_secret_basic or client_secret_post can be stored the way passwords are, as a hashTurning data into a short, fixed-size value called a hash, in a way that cannot be reversed and where changing one character changes the result completely. Services store password hashes instead of passwords, and signatures are made over a hash.. The server compares a hash of the presented secret with the stored hash, so a copy of its database does not reveal working secrets. A secret used with client_secret_jwt cannot be stored that way, because the server needs the secret itself to check each signatureA value made with a private key that lets anyone holding the matching public key check that a message came from the key's holder and has not been changed. It proves origin and integrity; it does not hide the message..
On the client side, the secret belongs in a secrets store or protected configuration, loaded by the backend at run time. It does not belong in source code, in a file committed to a repository, or in a shared document that developers pass around. Each extra copy is another place it can leak from, and a secret looks the same whether the printer or someone else presents it.
The weakness is built in. Every token request sends the secret to the server. Anything that records requests in full, such as a misconfigured proxy or a debugging log, can capture it, and a captured secret works until someone notices and replaces it.
Signing a client assertion
With private_key_jwt, the printer generates a key pair. It keeps the private key on its backend, ideally in a key management service or hardware module that can sign without ever revealing the key, as Storing and using keys described. It registers only the public keyThe half of a key pair that can be shared freely. It checks signatures made with the matching private key and can encrypt data that only that private key can decrypt. with the photo service, either as a key setA JSON document, published at a fixed HTTPS address, that lists an issuer's current public keys so others can verify its signatures. It never contains private keys. pasted into the registration or as the address of a published key set that the server can fetch.
For each token request, the printer creates a short JWTA JSON Web Token: a compact token made of Base64url-encoded parts that carries claims and is usually signed. Anyone holding it can decode and read the claims, so the signature shows who issued it but hides nothing. about itself, called a client assertion. Its header names the key that signed it and says what kind of JWT it is:
Header:
{
"alg": "ES256",
"kid": "printer-2026-10",
"typ": "client-authentication+jwt"
}
Claims:
{
"iss": "photo-printer",
"sub": "photo-printer",
"aud": "https://auth.photos.example",
"iat": 1790845200,
"exp": 1790845260,
"jti": "demo-client-assertion-118"
}All domains, identifiers, keys and credentials in these examples are fictional. The times are Unix timestamps, seconds since 1 January 1970, as in Time and timestamps.
Both iss and sub are the printer's client ID, because the printer is both making the statement and the subject of it. aud names the authorizationDeciding whether a requested action is permitted, such as whether a signed-in account may delete a particular photo. Authentication says which account is asking; authorization decides what it can do. server the assertion is meant for, using its issuer identifierThe party that creates and signs a token, assertion, or certificate, named in a token's iss claim. A recipient must check that the issuer is exactly the one it expected and trusts. as the only value. The assertion lasts one minute, and jti gives it a unique identifier.
That aud rule used to be looser. Servers accepted their token endpoint's URL, their issuer identifier, or sometimes a list of values. In 2025, researchers showed how a malicious authorization server could abuse that flexibility against a client that uses the same key with several servers. A client often learns a server's endpoint addresses from configuration the server publishes about itself, so a malicious server could list a genuine server's token endpoint as its own, get the client to sign assertions naming that address, and present them to the genuine server as the client. Current guidance for client assertions, from the bodies that maintain these specifications, closes the gap: the client uses the authorization server's issuer identifier as the single aud value, and the server rejects assertions with anything else. Another server cannot pass off that identifier as its own, because the client checks it against the address it used to find the server's configuration.
The same guidance asks clients to label the assertion with the typ value client-authentication+jwt, as the printer's header does. The label tells the server that the client follows the tighter aud rule. It is a signal, not the protection itself, so servers are advised not to reject assertions without it: many clients already follow the audience rule but have not added the label yet.
The printer signs the assertion and sends it in place of a secret:
POST /token HTTP/1.1
Host: auth.photos.example
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&code=demo-code-7
&redirect_uri=https%3A%2F%2Fprinter.example%2Foauth%2Fcallback
&code_verifier=btl_training_verifier_for_one_attempt_only_2026
&client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer
&client_assertion=eyJhbGciOiJFUzI1NiIsImtpZCI6InByaW50ZXItMjAyNi0xMCIsInR5cCI6ImNsaWVudC1hdXRoZW50aWNhdGlvbitqd3QifQ...The assertion is shortened here for display. Compare this with the JWT and SAML assertion grants lesson. There, the JWT was about a designer and took the place of the authorization code. Here, the JWT is about the client and takes the place of the client secret, while the authorization code is still present. The parameters are different too: client_assertion for authenticating the client, and assertion for a grant. client_assertion_type is a fixed, registered name saying that the assertion is a JWT; it looks long because it is written as a URN, a name that identifies something without being an address.
What the server checks
The authorization server works through the assertion before it considers the rest of the request:
- The
kididentifies a public key registered for this client, and the signature verifies with it using an algorithm the registration allows. issandsubboth equal the client ID the request is about.audis exactly this authorization server's issuer identifier.- The assertion has not expired, and its lifetime is short.
- If the server records
jtivalues to stop replays, as many do, this one has not been used before.
Only then does the server go on to check the code, the redirect URI, and the PKCE verifier, exactly as before.
Suppose a debugging log captured this whole request. The assertion inside it expires within a minute. A server that records jti values has already seen this one and refuses it, and even without that check, the window for replaying it is short. Nothing in the log lets anyone create a new assertion, because the private key was never in the request. The same log with a client secret in it would be an emergency.
Choosing between them
Client secrets remain common because they are easy to set up and every server supports them. For a small backend with one deployment and a good secrets store, a long random secret sent with HTTP Basic is a reasonable choice.
Signed assertions cost more effort: generating keys, publishing or registering the public key, and building a JWT for each request. In return, the credential never travels, the server stores nothing that could be used to impersonate the client, and the private key can live in hardware that will sign but never export it. Current security guidance prefers asymmetric methods such as private_key_jwt and mutual TLS where they are practical, and high-assurance profiles require them.
client_secret_jwt sits between the two. The secret no longer travels, but both sides still hold the same secret, so a leak from either side lets an attacker sign assertions. The secret also becomes an HMAC key, and a key for a hash-based signature must be at least as long as the hash output: 256 bits of randomness for HS256. A secret someone chose by hand, or one short enough to type, lets anyone holding a single captured assertion test guesses offline until the signature matches. It is less common than either neighbor.
Check your understanding
Try these questions before moving on. If an answer isn't right, use the feedback and try again.
Try it in the Lab
- Replace a shown-once secret with a signed client assertionSee how far a client secret travels and what a log keeps of it, then move lab-tmp-assertion-client to private_key_jwt with your own key pair and watch the tenant check, use once and refuse assertions.