Subscribe to the Non-Human & AI Identity Journal

Why do mobile apps need PKCE even when they already use an identity provider?

PKCE protects the authorization code exchange from interception and removes the need to embed a long-lived client secret in the app. In mobile environments, that matters because the binary can be inspected and runtime trust is weaker than on a server. PKCE makes the app safer by binding the token exchange to the original session.

Why This Matters for Security Teams

Using an identity provider does not remove the core mobile risk: the app is a public client running in an untrusted environment, so any embedded credential can be inspected, extracted, or replayed. PKCE closes that gap by binding the authorization code to the original session, which is why it is now a baseline expectation in modern OAuth guidance such as the NIST Cybersecurity Framework 2.0 and related platform guidance. The issue is not whether the IdP is trustworthy; it is whether the mobile runtime can safely prove continuity from login to token exchange.

NHI Management Group sees the same pattern across identity and secrets research: once a secret can be recovered from an app binary, the attacker no longer needs to “break” the IdP, they only need to reuse what the client exposed. That is consistent with broader findings in the Ultimate Guide to NHIs and the Top 10 NHI Issues, where long-lived credentials and weak lifecycle controls remain common failure points. In practice, many security teams discover mobile token abuse only after intercepted codes or copied app credentials have already been replayed.

How It Works in Practice

PKCE works by having the mobile app generate a one-time code verifier and code challenge at the start of the login flow. The app sends the code challenge to the identity provider, then later presents the original verifier when redeeming the authorization code. If an attacker intercepts the code, they still cannot exchange it without the verifier that never leaves the original client session.

That design matters because a mobile app should be treated as a public client, not as a trusted secret holder. A few practical implications follow:

  • Do not embed a long-lived client secret in the app binary. It can be recovered.
  • Use PKCE for every authorization code flow on mobile, including first-party apps.
  • Keep tokens short-lived and bind them to platform-safe storage where possible.
  • Prefer native system browsers or approved auth sessions over embedded webviews when the IdP supports them.

PKCE is not a substitute for secure token storage, device posture checks, or runtime protections. It addresses interception during the code exchange, which is a narrow but critical part of the login sequence. For broader mobile identity risk, the IOS app secrets leakage report shows how often mobile applications expose credentials through reverse engineering, logging, or weak local storage. When combined with current OAuth practice and platform controls described in the NIST Cybersecurity Framework 2.0, PKCE becomes the default way to protect public clients. These controls tend to break down when legacy mobile SDKs still depend on embedded secrets because the migration path is often incomplete.

Common Variations and Edge Cases

Tighter OAuth controls often increase implementation complexity, so teams have to balance security against app compatibility and release velocity. That tradeoff is real, especially when older identity stacks were built before PKCE was widely adopted.

Current guidance suggests a few common edge cases:

  • Native apps: PKCE should be used even when the app belongs to the same organisation as the IdP.
  • Confidential clients: A mobile app is usually not a confidential client in the security sense, even if it talks to a private backend.
  • Webviews: Some IdPs discourage them because they weaken the browser-mediated security model and can complicate session isolation.
  • Legacy integrations: Older authorization flows may still rely on client secrets, but best practice is evolving toward PKCE-first designs.

One point often missed is that PKCE protects the front-channel code exchange, not every possible OAuth failure mode. It will not fix weak redirect URI validation, overbroad scopes, compromised devices, or token theft after issuance. For that reason, mobile identity design should be read alongside broader NHI governance such as the 52 NHI Breaches Analysis, which shows how attackers pivot once a valid identity artifact is obtained. Where apps must support constrained devices, vendor-specific auth constraints, or deeply embedded enterprise mobile tooling, the guidance can become harder to apply cleanly because those environments often lag behind current OAuth security baselines.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0 and NIST AI RMF set the governance and control requirements practitioners need to meet.

Framework Control / Reference Relevance
OWASP Non-Human Identity Top 10 NHI-03 Emphasises protecting credentials that should not be embedded in clients.
NIST CSF 2.0 PR.AC-4 Covers access control enforcement for identity-based application flows.
NIST AI RMF Supports risk-aware identity decisions in untrusted execution environments.

Eliminate long-lived secrets in mobile apps and prefer ephemeral, exchange-bound auth flows.