Skip to content

client_secret_basic header generator

Encode a client id and secret into the client_secret_basic Authorization header, or decode one to check what it holds.

Runs in your browser. Nothing you paste is sent to us.

Client

A sample value is filled in. Whatever you type stays in this page.

Header

Authorization header value
Basic d2ViLWFwcDpzYW1wbGUtc2VjcmV0LW5vdC1yZWFs
curl option
-H 'Authorization: Basic d2ViLWFwcDpzYW1wbGUtc2VjcmV0LW5vdC1yZWFs'
step 1
web-app:sample-secret-not-realForm-encode id and secret, join with a colon
step 2
d2ViLWFwcDpzYW1wbGUtc2VjcmV0LW5vdC1yZWFsBase64 of the UTF-8 bytes
step 3
Basic <value>Send it in the Authorization header
Base64 is an encoding, not encryption: anyone who sees the header can read the secret. Send it only over https, and never from a browser or mobile app.

How to use it

  1. Enter the client id and secret.
  2. Copy the header value or the curl option.
  3. Switch to Read a header to decode one you already have.

What to know

client_secret_basic sends Authorization: Basic followed by Base64 of client_id:client_secret. RFC 6749 says to form-encode the id and secret first, so a colon or other special character survives.

For ids and secrets of only letters, digits and - . _ the result is the same either way. The tool shows both when they differ.

Base64 is not encryption. Send the header only over https, and only from a back end.

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.

Sample header (made-up client and secret)
client id:      web-app
client secret:  sample-secret-not-real
joined:         web-app:sample-secret-not-real
header:         Authorization: Basic d2ViLWFwcDpzYW1wbGUtc2VjcmV0LW5vdC1yZWFs

The 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.

Sample encoding (made-up values)
form-encoded:   billing%3Ajob:s3cret%2Bkey%2F2
RFC 6749 header: Basic YmlsbGluZyUzQWpvYjpzM2NyZXQlMkJrZXklMkYy
plain header:    Basic YmlsbGluZzpqb2I6czNjcmV0K2tleS8y

A 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

  1. Choose Make a header.
  2. Enter the client id exactly as registered, including its case.
  3. Enter the client secret.
  4. Copy the header value, or the ready -H option for curl.
  5. 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

MethodHow the client proves itselfNotes
client_secret_basicSecret in the Authorization header.Default in OpenID Connect.
client_secret_postclient_id and client_secret in the form body.Same secret, different place.
client_secret_jwtA JWT signed with the secret using HMAC.The secret itself is never sent.
private_key_jwtA JWT signed with the client’s private key.The server holds only the public key.
noneNothing; 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_basic and client_secret_post for 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 Basic prefix 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_jwt for services that can manage a key pair.
Questions

Frequently asked questions

How do I create a Basic auth header for OAuth client credentials?

Form-encode the client id and the secret, join them with a colon, Base64-encode the result and send `Authorization: Basic <value>`. For ids and secrets of only letters and digits, the form-encoding step changes nothing.

Why does RFC 6749 form-encode the client id and secret first?

So special characters, above all a colon, survive. Without it, the server could not tell where the client id ends and the secret begins.

Is the Basic header encrypted?

No. Base64 is reversible by anyone. The header is only safe over HTTPS and must never be logged.

What is the difference between client_secret_basic and client_secret_post?

Both send the same secret. Basic puts it in the Authorization header; post puts `client_id` and `client_secret` in the form body. Keycloak accepts both.

Can I use curl -u for OAuth client authentication?

Yes when the id and secret contain only letters, digits and a few safe characters. `curl -u` does not form-encode, so with special characters the header differs from what RFC 6749 describes.

Why does my token request return invalid_client?

The secret is wrong or was regenerated, the client id is not in this realm, or the client expects another authentication method. Decode the header you send and compare it with the client’s settings.

Where do I find the client secret in Keycloak?

Open the client in the admin console and go to its Credentials tab. The tab appears only when Client authentication is on. You can copy or regenerate the secret there; regenerating breaks apps that still use the old one.

How do I decode a Basic authorization header?

Remove the word Basic, Base64-decode the rest and split at the first colon: the left part is the client id, the right part the secret. If the client followed RFC 6749, form-decode both parts as well. The Read a header mode does all of this.

Should a single-page app use a client secret?

No. Code in a browser cannot keep a secret. A single-page app is a public client and uses the authorization code flow with PKCE.

Rather not run Keycloak yourself?

We run it for you on a cluster of your own, with backups, upgrades and written support. Starter and Premium begin with a 7-day trial.