Why clients authenticate
An OAuth client that can keep a secret is called a confidential client. Web apps with a back end and services are confidential. When such a client calls the token endpoint, the server needs proof that it really is that client. Otherwise anyone who knew a client id could redeem its codes or ask for its tokens.
RFC 6749 section 2.3 describes client authentication. The simplest method is a client secret, a shared password the server issues to the client. The question is where to put it in the request.
What client_secret_basic is
With client_secret_basic the client sends its id and secret in the HTTP Authorization header, using the Basic scheme from HTTP authentication. RFC 6749 section 2.3.1 says servers must support this method for clients that have a secret. OpenID Connect calls it client_secret_basic, and OpenID Connect Dynamic Client Registration makes it the default when a client names no other method.
The header value is the word Basic, a space, and the Base64 encoding of the client id, a colon and the secret.
client id: web-app
client secret: sample-secret-not-real
joined: web-app:sample-secret-not-real
header: Authorization: Basic d2ViLWFwcDpzYW1wbGUtc2VjcmV0LW5vdC1yZWFsThe encoding step most libraries skip
There is a detail that trips people up. RFC 6749 says the client id and secret are first encoded with the application/x-www-form-urlencoded rules, and only then joined with a colon and Base64-encoded. In that encoding, letters, digits and *-._ stay as they are, a space becomes +, and everything else becomes a percent code. A colon becomes %3A, an exclamation point %21.
The point is safety: a colon in the client id would otherwise make it impossible to tell where the id ends and the secret starts.
Many clients and servers skip this step and Base64-encode the raw values. For ids and secrets made only of letters, digits and -._, both ways give the same header, so nobody notices. The difference appears only when a secret contains characters such as +, /, =, % or a colon.
If a server rejects a header with special characters, try the variant without form encoding, or send the secret in the body with client_secret_post.
A worked example with special characters
Take a made-up client id billing:job and secret s3cret+key/2. Both contain characters that form encoding changes: the colon, the plus sign and the slash.
form-encoded: billing%3Ajob:s3cret%2Bkey%2F2
RFC 6749 header: Basic YmlsbGluZyUzQWpvYjpzM2NyZXQlMkJrZXklMkYy
plain header: Basic YmlsbGluZzpqb2I6czNjcmV0K2tleS8yA server that follows RFC 6749 decodes the Base64, splits at the first colon and form-decodes each half. It gets back billing:job and s3cret+key/2. A server that skips form decoding would read the id as billing%3Ajob and fail.
With the plain header, the opposite happens. Splitting at the first colon gives a client id of billing and a secret of job:s3cret+key/2. A server that form-decodes would also turn the plus sign into a space. Either way, authentication fails.
This is why the safest secret is one that needs no encoding at all.
What this tool does and does not do
The tool has two modes.
- Make a header: enter the client id and secret, and get the header value and a curl option. It follows RFC 6749 and form-encodes first. When that changes the result, it also shows the plain variant.
- Read a header: paste a Basic header, with or without
Authorization:in front, and see the client id and secret it holds, decoded both raw and form-decoded. - It shows the steps: the encoded pair, the Base64 value and the final header.
It does not send anything and does not check the secret against a server. It does not build client_secret_jwt or private_key_jwt assertions. The token request builder accepts a signed JWT you paste.
How to use the tool
- Choose Make a header.
- Enter the client id exactly as registered, including its case.
- Enter the client secret.
- Copy the header value, or the ready
-Hoption for curl. - To check a header from logs or code, switch to Read a header and paste it.
A sample id and secret are filled in. Whatever you type stays in the page.
Where it helps
Debugging invalid_client
When a token request fails with invalid_client, decode the header your app sends. A trailing newline in the secret, the wrong client id or a secret from another environment shows up at once.
Calling the token endpoint by hand
Testing with curl is faster with a header you can paste. The tool’s header is always correct for RFC 6749, while curl -u sends the raw values.
Introspection and revocation
The same header authenticates the client at the introspection and revocation endpoints. An API that introspects tokens usually does it with its own client’s Basic header.
Other ways to authenticate a client
| Method | How the client proves itself | Notes |
|---|---|---|
client_secret_basic | Secret in the Authorization header. | Default in OpenID Connect. |
client_secret_post | client_id and client_secret in the form body. | Same secret, different place. |
client_secret_jwt | A JWT signed with the secret using HMAC. | The secret itself is never sent. |
private_key_jwt | A JWT signed with the client’s private key. | The server holds only the public key. |
none | Nothing; only client_id. | For public clients, which rely on PKCE. |
The JWT methods come from OpenID Connect Core section 9 and RFC 7523. They send client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer and the signed client_assertion.
How Keycloak handles client secrets
In Keycloak, a client with Client authentication on is confidential. Its Credentials tab shows the client authenticator and, for secret-based methods, the current secret.
- Keycloak accepts both
client_secret_basicandclient_secret_postfor a client that authenticates with a client id and secret. - Signed JWT methods are separate authenticators, chosen in the same tab.
- You can regenerate a secret from the Credentials tab. Apps that still hold the old one then get
invalid_client.
The token endpoint is https://<host>/realms/<realm>/protocol/openid-connect/token. A client id is unique only within its realm, so the realm in the URL must be right too.
Common errors and how to fix them
invalid_client: the secret is wrong or was rotated, or the client id is unknown in this realm. Decode the header and compare.unauthorized_client: authentication worked, but the client may not use this grant. Check its capability settings.- A 401 with a valid secret: the header may have a doubled
Basicprefix or an extra space. - Works in curl, fails in code: the library may form-encode differently. Compare both variants in this tool.
See the OAuth error lookup for the full list of codes.
Security notes
Base64 is an encoding, not encryption. Anyone who sees the header can read the secret, so send it only over HTTPS and never log the header.
Never ship a client secret in a browser or mobile app. Those are public clients; they use PKCE instead. RFC 9700 also recommends asymmetric methods, such as private_key_jwt or mutual TLS, where a server can, because the server then never stores a secret that could leak.
Rotate secrets on a schedule and after any suspected leak.
Best practices
- Keep secrets in a secret store, not in source code.
- Use letters and digits only when you choose a secret yourself, so every library encodes it the same way.
- Use one client per app and environment, each with its own secret.
- Prefer
private_key_jwtfor services that can manage a key pair.