Combining PKCE and a Client Secret for Auth0 Applications
Last Updated:
Overview
Administrators often inquire whether combining Proof Key for Code Exchange (PKCE) and a client secret enhances security across Auth0 application types.
While the draft OAuth 2.1 specification recommends or requires PKCE for all client types (including Single-Page Applications, Native apps, and Regular Web Applications), combining PKCE with a client secret is only recommended for confidential clients (such as Regular Web Applications).
Using a client secret within public clients (Single-Page Applications and Native applications) is not recommended and presents a significant security risk because credentials cannot be securely stored on the front end or in distributed client code.
Applies To
- Auth0
- Proof Key for Code Exchange (PKCE)
- Client Secret
- Regular Web Applications (Confidential Clients)
- Single-Page Applications (Public Clients)
- Native / Mobile Applications (Public Clients)
- OAuth 2.0 / OAuth 2.1
Cause
Confusion frequently arises around OAuth 2.1 guidelines regarding PKCE adoption. While OAuth 2.1 mandates PKCE across all client types to prevent authorization code interception and injection attacks, it does not mandate or recommend deploying client secrets to public clients.
Solution
When do administrators combine PKCE with a client secret?
The decision to combine PKCE with a client secret depends on whether the application functions as a confidential client or a public client.
Regular Web Applications (Confidential Clients)
-
Recommendation: Combine PKCE with a
client_secret.Regular web applications run code on a secure backend server capable of keeping credentials confidential. In line with OAuth 2.1 recommendations, using PKCE alongside application authentication (via the
client_secret) provides defense-in-depth:-
PKCE protects against authorization code interception and injection attacks.
-
The
client_secretensures that only the authenticated backend application can exchange the code for tokens.
-
-
For implementation details, refer to the Authorization Code Flow with PKCE - Get Token endpoint documentation, where
client_secretis supported as an optional parameter for confidential clients.
Single-Page Applications (SPAs) & Native / Mobile Apps (Public Clients)
-
Recommendation: Use PKCE without a
client_secret.Public clients run in environments (browsers, mobile devices, desktop operating systems) where code and storage can be inspected, decompiled, or intercepted:
-
Hardcoding or delivering a
client_secretto an SPA or mobile app exposes that secret to anyone inspecting network requests or application binaries. -
Exposing a client secret compromises application security and violates basic credential management principles.
-
-
Public clients must exclusively rely on the Authorization Code Flow with Proof Key for Code Exchange (PKCE) without passing a client secret.