Client authentication methods
A client ID names a client; it proves nothing. A confidential clientAn OAuth client, typically running on a backend, that can keep a credential such as a client secret or private key protected, and so can authenticate itself to the authorization server. also has to show, on every direct request to 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., that it holds the credential registered for that ID. How it shows that is its client authentication method, and the method is part of its registration.
Proving which client is asking
When the printer exchanged its authorization codeA short-lived, single-use value that the authorization server sends back to a client through the browser. The client swaps it for tokens in a direct request to the authorization server; APIs never accept it., the token endpointThe authorization server address where clients exchange an authorization code, refresh token, or other grant for tokens, in a direct request rather than through a browser redirect. needed to know that the request really came from the printer. A stolen code alone should not be enough, and neither should knowledge of the client ID, which anyone can read in an 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. URLA web address, such as https://photos.example/api/albums/42?limit=10. It names how to connect (https), the domain, the path to a particular page or resource, and any extra parameters after the question mark.. The printer proved itself with an Authorization header holding its client ID and secret. That header was one choice among several, and OAuthA framework that lets a person give an application limited access to their resources at another service, using tokens instead of sharing their password. OAuth is about access; OpenID Connect adds sign-in. calls the general idea client authentication.
Client authentication happens where a confidential client talks directly to the authorization server: the 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. endpoint in every flow we have followed, and other back-channel endpoints, such as those that Token introspection and Token revocation cover. It does not happen in the browser. An authorization request carries only the client ID, because anything placed in a browser URL can be seen by the person using it and by anything that records it.
The goal is always the same: show that the request comes from the party holding the credential registered for this client ID. The methods differ in what that credential is and how much of it travels with each request.
Methods side by side
Registrations name the method with a standard value. These are the ones you will meet most often:
| Method | What the client sends |
|---|---|
client_secret_basic | Its client ID and shared secret in an HTTP Basic Authorization header, joined with a colon and Base64-encoded. |
client_secret_post | Its client ID and shared secret as fields in the request body. |
client_secret_jwt | A short-lived JWT signed with the shared secret, which must be long and random enough to serve as an HMAC key. The secret itself is not sent. |
private_key_jwt | A short-lived JWT signed with the client's private key. The server holds only the public key. |
tls_client_auth and self_signed_tls_client_auth | A client certificate, presented while the TLS connection is set up, the way a server presents its own certificate to a browser. |
none | Only its client ID. This is how a public client is registered. |
The first two send the secret itself. RFC 6749, the OAuth 2.0 specification, requires an authorization server that issues client secrets to support HTTPThe Hypertext Transfer Protocol, the rules browsers, apps, and servers use to send requests and responses on the web. Basic, which is why the earlier examples used it. One detail catches many developers: before the client ID and secret are joined with a colon and Base64-encoded, each must be percent-encoded the way a form field is, so a secret containing characters such as + or : is escaped first. A colon left as it is would split the pair in the wrong place. A client that skips this step works with simple secrets and then fails mysteriously with one that contains punctuation.
Sending the secret in the body instead looks like this:
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_id=photo-printer
&client_secret=demo-only-not-a-real-secretAll domains, identifiers, and credentials in these examples are fictional.
The protection is the same as with Basic. HTTPSHTTP protected by TLS, so traffic is encrypted and checked for changes while it travels. It protects the connection, but does not prove that the site at the other end is honest. hides the secret in transit, and the server compares it with what it holds. RFC 6749 recommends the header form and allows body fields only for clients that cannot use it. The OAuth 2.1 draft reverses that preference because so many implementations got the encoding step wrong: it requires servers to accept the body form and makes Basic optional. Whichever form a client uses, check how its logs treat the secret: many tools that record requests already know to hide an Authorization header, while a secret in an ordinary form field looks like any other field.
The 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. methods take a different approach. The client never sends a reusable secret. It sends a signed JWT stating that it is the client, valid for a few minutes, and the server checks the 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., as Digital signatures described. With private_key_jwt, the server does not hold anything that could be used to create such a statement. The certificate methods move the proof into the TLS connection itself and can also bind the tokens issued to that certificate. Secrets and signed assertions examines the JWT methods in detail, and Authenticating a client with a certificate, in Advanced OAuth, covers mutual TLS.
One method per registration
The printer's registration says client_secret_basic. A careful authorization server holds it to that. A request from photo-printer that puts the secret in the body instead, or offers a JWT, is rejected even if the credential inside it is correct.
That can seem pedantic, but it closes real gaps. If a client registered for private_key_jwt could also present a shared secret, then whatever secret the server still held for that client would become a second way in, and the stronger method would protect nothing. A request must also use only one method at a time: RFC 6749 says a client must not use more than one in the same request. One that carries both a Basic header and a body secret is malformed, not doubly authenticated, so the server refuses it as invalid_request, although some servers report it as invalid_client instead.
Public clients are the other side of this rule. A client registered with none cannot authenticate, so the server relies on other protections, such as PKCE and exact redirect URI matching. It should not treat a public client that sends a made-up secret as if it were confidential.
photo-printer
- Client type
- confidential
- Client authentication
- client_secret_basic
The correct secret in every request
Checked against the registered method
- Basic Authorization header
- client_secret in the request body
- Both a Basic header and a body secret
- Only its client ID
Only the first is accepted
The wrong method is rejected even if the credential inside it is correct.
When authentication fails
A wrong secret, an unknown client ID, or the wrong method produces an invalid_client error. When the client tried HTTP Basic, the server answers with status 401 and a WWW-Authenticate header, the standard HTTP way of saying which kind of authentication the endpoint expects:
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Basic realm="auth.photos.example"
Content-Type: application/json
Cache-Control: no-store
{
"error": "invalid_client"
}The response does not say which part was wrong. Telling a caller "that client exists, but the secret is wrong" would help someone guessing at secrets. For the same reason, servers limit how many failed attempts they accept for a client.
For the printer, invalid_client is rarely something a retry will fix. It usually means the deployed credential does not match the registration: a secret was replaced but not updated in one place, or a new key was not yet registered.
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
- Hold a client to one authentication methodRead the tenant's supported methods, authenticate correctly, move lab-print-orders from the header to the body and back, and see other ways of presenting a credential refused, including a public client's secret.