Prompt
What should I use for login across web, mobile, and API services?
Latest observation
Oct 28, 2026
OpenAI APIWeb search: off
For web, mobile, and API services, the best default is:
Use OAuth 2.1 + OpenID Connect (OIDC) with an external Identity Provider
Examples: Auth0, Okta, AWS Cognito, Azure AD B2C, Google Identity Platform, Keycloak
Why this is usually the right choice
- Web app: supports browser-based sign-in cleanly
- Mobile app: supports system browser / app-to-app login flows
- API services: issues access tokens your APIs can verify
- Single sign-on (SSO): one identity across all platforms
- Password handling is offloaded: less security risk and less work
- MFA, social login, enterprise login: usually built in
Recommended flow by client type
1) Web app
Use:
- Authorization Code Flow + PKCE
- Prefer server-side session cookies for your own web app session after login
2) Mobile app
Use:
- Authorization Code Flow + PKCE
- Open the login page in the system browser or secure auth session
- Store refresh tokens carefully using OS secure storage
3) API services
Use:
- Bearer access tokens issued by the IdP
- APIs validate JWTs or introspect opaque tokens
- For service-to-service, use client credentials flow
What not to use
- Do not build your own password system unless you have a strong reason
- Avoid:
- password-based auth embedded directly in mobile apps
- deprecated Implicit Flow
- long-lived API keys for end-user login
- storing tokens in insecure client storage
Common architecture
- User clicks “Sign in”
- Client redirects to identity provider
- User authenticates there
- App receives an authorization code
- App exchanges code for tokens
- Web app creates a session cookie or mobile app stores tokens securely
- API calls include access token
Best-practice token model
- ID token: for the client to know who signed in
- Access token: for calling APIs
- Refresh token: to get new access tokens, used carefully and rotated
If you want the shortest recommendation
Use OIDC on top of OAuth 2.1, with Authorization Code + PKCE everywhere, backed by a dedicated identity provider.
If you want, I can also recommend a setup based on your stack, like:
- React + iOS/Android + Node/Go APIs
- SPA + mobile + microservices
- B2C vs internal enterprise app