Safeguard
Security Guides•

Private key JWT or client secret for OAuth client authentication?

RFC 9700 recommends asymmetric client authentication, such as private key JWT, so servers need not store shared secrets. How it works and when to switch.

Safeguard Security Team
4 min read

Prefer private key JWT where your authorization server supports it. RFC 9700 recommends asymmetric client authentication, such as mutual TLS or signed JWTs, because the server needs to store only public keys, which makes leakage less damaging. A client secret is simpler but is a shared secret that must be stored on both sides.

How each works

Client secret. The client and server share a password. The client sends it, often with HTTP Basic authentication, when calling the token endpoint. Anyone who obtains the string can act as the client.

Private key JWT. The client registers a public key. To authenticate, it signs a short JWT with its private key and sends it as the client_assertion. The server verifies the signature with the public key. The private key is never transmitted.

What the signed JWT contains

The OpenID Connect Core spec lists the claims for the private_key_jwt method:

ClaimRequirement
issRequired, the client_id
subRequired, the client_id
audRequired, identifies the authorization server, ideally the token endpoint URL
jtiRequired, a unique ID so the token can be used only once
expRequired, the expiry
iatOptional

The client_assertion_type parameter must be urn:ietf:params:oauth:client-assertion-type:jwt-bearer. The spec says the server must verify it is an intended audience, and that these tokens must only be used once unless reuse is negotiated.

Comparison

QuestionClient secretPrivate key JWT
What does the server store?A secret or its hashA public key
If the server database leaksClient secrets may be exposedPublic keys only
If the client leaks its credentialAttacker can authenticate until rotatedAttacker can authenticate until the key is revoked
Setup effortLowHigher: key generation, signing code
RotationReplace the stringPublish a new key, then retire the old
Replay protectionNone built injti and short exp

The main gain is on the server side. RFC 9700 says that with asymmetric client authentication, authorization servers do not need to store sensitive symmetric keys. That removes one source of leakage.

When to switch

  1. You operate many confidential clients and want to reduce the blast radius of a database leak at the authorization server.
  2. You can store a private key in a managed key service or hardware module instead of a config file.
  3. Your authorization server supports the method. Check its metadata for the supported authentication methods.
  4. You can handle key rotation. Publishing keys through a JWKS URL makes this easier.

Stay with a client secret if the cost of the change outweighs the risk, but treat the secret as a high value credential: keep it in a secrets manager, rotate it on a schedule, and never log it.

Implementation tips

  • Set a short exp, such as one minute, and a fresh jti per request.
  • Set aud to the token endpoint URL.
  • Sign with a modern algorithm and publish the kid.
  • Do not reuse the same key for signing client assertions and other purposes.
  • Alert when a client authenticates from a new location.

Quick check

Does private key JWT fix a stolen token?

No. It protects client authentication, not tokens already issued. Use short lifetimes and sender constraining for tokens.

Can public clients use it?

It only helps when the private key can be kept safe. A key shipped inside an app can be extracted, so public clients rely on PKCE instead.

Safeguard's SBOM and dependency scanning shows which OAuth and JWT libraries your services use, which matters when you add signing code. Start with the free scan.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.