Use an OAuth style flow designed for public clients, with PKCE, a browser based sign-in surface, and a redirect URI that returns into the app. Keep only short lived access tokens in memory and store refresh tokens in encrypted, device backed storage. The app should never ship a secret, because anything inside an APK can be extracted.
Why public-client sign-in is the right pattern here
A mobile app that cannot safely hold a client secret should be treated as a public client, not as a confidential one. That means the app proves the sign-in request with PKCE and completes the user journey in a browser-based sign-in surface, then returns to the app through a registered redirect URI. The design goal is to avoid putting long-lived trust material inside the app package.
For mobile teams, the important distinction is that the app can still participate in OAuth without ever becoming a secret-bearing client. The browser handles the user authentication step, the app receives the authorization response, and the back end or identity provider can then issue tokens under the protections appropriate for a public client.
When this pattern is implemented well, the app does not need a shipped secret at all. That matters because anything embedded in an APK can be reverse engineered, copied, or replayed outside the intended device and user context.
Token handling and storage boundaries
The safest mobile pattern is to keep only short-lived access tokens in memory and to store refresh tokens only where the platform provides encrypted, device-backed protection. On iOS that typically means Keychain-backed storage; on Android, Keystore-backed wrapping or an equivalent device-bound mechanism. The practical objective is to reduce the lifetime and portability of anything that can be used to continue a session.
This is also where many implementations drift into unsafe shortcuts. If a mobile client starts caching bearer material in plain preferences, local files, logs, or JavaScript bridges, the sign-in design is undermined even if the OAuth flow itself is correct. Good mobile sign-in is as much about token custody as it is about the initial login exchange.
For guidance on the broader mobile control set around PKCE, secure local storage, attestation and app testing, see the Mobile App Security Guide and the OWASP Mobile Top 10 M1 Improper Credential Usage Guide.
What to avoid when adapting OAuth for mobile
The main design error is to mimic server-side OAuth by embedding a client secret in the app and hoping it stays hidden. A second common error is to rely on a webview or custom session logic that weakens browser isolation or makes redirect handling fragile. Both failures create unnecessary exposure, because the attacker only needs local access or reverse-engineering capability to recover the secret or abuse the flow.
A better architecture is to prefer browser-mediated sign-in, use PKCE to bind the authorization response to the initiating app instance, and keep the redirect URI narrowly registered. If the app also needs stronger proof of possession or device trust, add those controls without turning the mobile client into a secret vault.
If your team wants a broader reference for replacing shipped secrets with stronger client authentication patterns, Static vs Dynamic Secrets and the JWT Client Authentication Guide are useful complements, even when the mobile app itself remains a public client.
Risk and Threat Considerations
Mobile client secrets are exposed to reverse engineering, repackaging, and extraction from device storage or memory, so any secret embedded in the app expands the attack surface instead of securing it. Once extracted, that secret can be reused from outside the intended app context and can enable unauthorized token issuance, impersonation, or API abuse.
Failure mechanism: The app package, runtime memory, or local storage becomes the weakest link, allowing an attacker to recover the client secret or refresh token and replay it elsewhere.
Impact: The result can be unauthorized sign-in, session theft, broader API access, and a compromise that persists until the exposed credential is rotated or revoked.
Standards & Framework Alignment
This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.
OWASP API Security Top 10 addresses the attack and risk surface, while OWASP ASVS, NIST SP 800-53 Rev 5 and CIS Controls v8 set the governance and control requirements practitioners need to meet.
| Framework | Control / Reference | Relevance |
|---|---|---|
| OWASP ASVS | V10 — OAuth and OIDC | Mobile sign-in uses OAuth/OIDC flows and PKCE for native clients. |
| Recommendation — Use V10 to require PKCE and correct OAuth/OIDC client handling in the mobile sign-in flow. | ||
| NIST SP 800-53 Rev 5 | IA-5 — Authenticator Management | Refresh tokens and other bearer material need lifecycle protection and revocation control. |
| IA-9 — Identification and Authentication (Non-Organizational Users) | The app is authenticating to an external identity service as a client context. | |
| Recommendation — Apply IA-5 to manage token lifecycle, storage, rotation, and revocation. Use IA-9 to enforce strong client authentication and token handling for the mobile app. | ||
| OWASP API Security Top 10 | API2 — Broken Authentication | If mobile sign-in is implemented incorrectly, token and auth flows can be abused. |
| Recommendation — Review API authentication endpoints to ensure authorization-code and token exchange handling is robust. | ||
| CIS Controls v8 | CIS-5 — Account Management | Mobile session and token lifecycle directly affect account access continuity and revocation. |
| Recommendation — Use CIS-5 to ensure exposed sessions and credentials can be revoked quickly. | ||
Practitioner Guidance
What to verify: Confirm that the mobile app is registered as a public client, that PKCE is enforced, and that the redirect URI is exact-match registered rather than broadly wildcarded. Also verify that no build artifact, config file, or runtime path contains a reusable secret.
What good looks like: A successful sign-in depends on the browser and the authorization server, not on a secret hidden in the app binary. The app holds only transient state in memory, while refresh tokens are protected by platform-backed encryption and can be revoked cleanly if the device or account is at risk.
Practitioner takeaway: If the client cannot protect a secret with the same assurance as a server, do not force confidential-client patterns into it, use public-client OAuth correctly and move trust into short-lived, device-bound token handling.
Related resources from NHI Mgmt Group
- Guide: Machine-to-Machine OAuth (Client Credentials) Guide
- How should security teams implement Client ID Metadata Documents?
- How should security teams implement PKCE-based sign-in in native mobile apps without exposing secrets in the app bundle?
- How should mobile security teams implement device fingerprinting so it supports fraud detection without overrelying on the client app?
- How should security teams implement mobile app risk management across the enterprise?
Deepen Your Knowledge
Free weekly newsletter
Subscribe to the NHI & AI Identity Journal
The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.
Bonus 33% off our NHI Course when you subscribe.
Reviewed and updated by the NHIMG editorial team on November 2, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org