Client Types: Public vs Confidential Clients
How to choose between a public client (PKCE-only) and a confidential client (client secret) — and what changes in the token request.
Every Securely Connect client has a client type that is set when the client is registered. There are two:
CONFIDENTIAL— your client can keep a secret. It authenticates to the token endpoint with aclient_secret.PUBLIC— your client cannot keep a secret. It authenticates with PKCE only and never sends a secret over the wire.
This is independent of your party type (SECOND/THIRD). For example, a second-party partner might run a confidential client on their server, or a public client in a customer's browser — both are valid.
How to choose
The rule is short:
If your code runs anywhere the user can read it, you're a public client.
| Where your client runs | Recommended type |
|---|---|
| Server you control (backend service, daemon, scheduled job) | CONFIDENTIAL |
| Single-page app (React, Vue, Angular) | PUBLIC |
| Native mobile app (iOS, Android) | PUBLIC |
| Native desktop app (Electron, .NET MAUI) | PUBLIC |
| CLI tool installed on user machines | PUBLIC |
A secret embedded in a binary, an .env file shipped to customers, or a JS bundle is not a secret. Treat it as public.
What changes between the two
Confidential client — token request
A confidential client sends client_id and client_secret to /oauth/token. The auth server's metadata advertises token_endpoint_auth_methods_supported: ["client_secret_post"], so the secret goes in the form body (not the Authorization header).
curl -X POST https://auth.securely.io/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=YOUR_CLIENT_ID" \
-d "client_secret=YOUR_CLIENT_SECRET"Public client — token request
A public client sends client_id and a code_verifier (proving it started the authorization request). No secret is involved.
curl -X POST https://auth.securely.io/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=authorization_code" \
-d "code=AUTH_CODE_FROM_CALLBACK" \
-d "redirect_uri=https://your.app/callback" \
-d "client_id=YOUR_CLIENT_ID" \
-d "code_verifier=ORIGINAL_VERIFIER"Grant types available to each
| Grant | Public | Confidential |
|---|---|---|
authorization_code (with PKCE) | ✓ | ✓ |
refresh_token | ✓ | ✓ |
client_credentials | ✗ | ✓ |
client_credentials is only available to confidential clients — you cannot do machine-to-machine authentication with a public client. That's by design: there's no user to consent and no secret to authenticate with.
What if my client crosses both worlds?
A common pattern: a SPA that talks to a thin Backend-For-Frontend (BFF). The browser side is public, the BFF is confidential. The right model is to register two clients — one public for the browser, one confidential for the BFF — and use each for its appropriate flow.
Don't ship a confidential secret to a browserIf you're tempted to put a confidential client's secret in your SPA bundle so you can call
client_credentialsdirectly, stop. Register a public client instead, use PKCE, and let the user log in. Or move the call to a backend.
Security tradeoffs
| Concern | Public | Confidential |
|---|---|---|
| Secret can leak from your code | N/A (no secret) | High consequence if leaked |
| Replay protection for the authorization code | PKCE binds the code to the original requester | client_secret + PKCE if used |
| Rotation | Not needed (no secret) | Rotate via /clients/{id}/rotate-secret |
Confidential clients have a higher operational burden — secrets must be stored in a vault, rotated periodically, and never logged. Public clients have none of that, but they cannot perform machine-to-machine flows.
Updated 7 months ago
What’s Next
Choosing Your OAuth Flow — combine party type + client type into a concrete plan.
