Prompt
How do I support passwordless sign-in in a browser and native app?
Latest observation
To support passwordless sign-in in both a browser and a native app, the most common and best-supported approach is:
Use OAuth 2.0 / OpenID Connect with Authorization Code + PKCE, and make the “login” step passwordless
You usually do not build passwordless into your app directly. Instead, you delegate authentication to an identity provider (IdP) that supports passwordless methods such as:
- Passkeys / WebAuthn
- Magic links
- OTP codes via email/SMS
- Push approvals
- Biometrics (typically through passkeys or platform authenticators)
Recommended architecture
1) Browser app
Use the OIDC Authorization Code Flow with PKCE:
- User clicks Sign in
- Your browser redirects to the IdP’s
/authorize - The IdP presents a passwordless option:
- passkey
- magic link
- OTP
- After successful authentication, the IdP redirects back with an authorization code
- Your app exchanges the code for tokens
2) Native app
Also use Authorization Code Flow with PKCE, but through the system browser:
- App opens the system browser to the IdP
/authorize - User completes passwordless authentication
- IdP redirects to a custom URI scheme or app link
- App receives the authorization code
- App exchanges the code for tokens
This is the standard secure pattern for native apps.
Best passwordless option: Passkeys
If you want the strongest and most modern passwordless experience, use passkeys:
- Browser: via WebAuthn
- Native app: via platform authenticators / passkey APIs
Why passkeys are ideal
- Resistant to phishing
- No shared secrets
- Works across devices
- Can be synced by OS/password managers
- Good UX on both web and mobile
Browser
Implement WebAuthn registration and authentication ceremonies.
Native app
Use platform APIs:
- iOS: AuthenticationServices / passkeys
- Android: Credential Manager / passkeys
If you have your own backend, it must:
- generate registration/authentication challenges
- verify attestation/assertions
- store public keys and credential IDs
- track user accounts and authenticator metadata
If you want one login system for both apps
A common setup is:
- Identity Provider handles passwordless
- Your apps are OIDC clients
- You configure:
- browser app client
- native app client
- Both use the same user directory and passwordless policy
Examples of IdPs that support this:
- Auth0
- Azure AD B2C / Microsoft Entra External ID
- Okta
- AWS Cognito (with some customization)
- Keycloak (with add-ons / custom flows)
- Firebase Auth (limited passwordless patterns)
- Custom auth backend
Implementation options
Option A: Use an identity provider
Best if you want fastest delivery.
Supports:
- Passkeys
- Email magic links
- OTP
- Social logins
- MFA
- Account recovery
Your apps only implement OIDC.
Option B: Build your own passwordless auth
More control, more work.
You’ll need:
- user enrollment
- challenge generation
- credential verification
- replay protection
- token issuance
- account recovery
- device management
- secure session handling
If you build your own, passkeys/WebAuthn are usually the right core mechanism.
Mobile app guidance
For native apps, avoid:
- embedding login in a webview
- using passwords
- storing long-lived tokens insecurely
Use:
- system browser for sign-in
- PKCE
- secure token storage:
- iOS Keychain
- Android Keystore / EncryptedSharedPreferences
Suggested flows
Passkey-first flow
- User enters email or username
- App/backend discovers available methods
- If passkey exists, prompt passkey sign-in
- If not, offer magic link / OTP / account recovery
- Complete OIDC login and issue tokens
Account recovery
Since passwordless can fail if the device is lost, you should support:
- backup passkeys
- recovery codes
- verified email/phone recovery
- admin/support-assisted recovery for enterprise
Security recommendations
- Use PKCE for all public clients
- Use short-lived access tokens
- Use refresh tokens with rotation
- Prefer passkeys over SMS OTP
- Do not use embedded webviews for auth
- Bind tokens to secure storage
- Support device revocation and session logout
- Add MFA only if your risk model requires it
Practical recommendation
If you’re starting from scratch:
- Choose an IdP that supports passkeys
- Implement OIDC Authorization Code + PKCE
- Use:
- browser redirect for web
- system browser + custom URI scheme/app links for native
- Make passkeys the default passwordless method
- Add magic link/OTP as fallback and recovery
If you want, I can also give you:
- a reference architecture diagram
- a browser + mobile sequence diagram
- or concrete examples for Auth0 / Cognito / Keycloak / custom WebAuthn