Prompt
I’m building a SaaS app and need users to sign in with Google and Microsoft — what auth approach should I use?
Latest observation
For a SaaS app where users sign in with Google and Microsoft, the best default is:
Use OAuth 2.0 + OpenID Connect (OIDC)
- OAuth 2.0 handles delegated authorization.
- OpenID Connect adds the actual authentication / sign-in layer on top of OAuth.
In practice, you should implement “Sign in with Google” and “Sign in with Microsoft” using their OIDC providers.
Recommended architecture
1) Use an identity/auth layer in your app
Your app should not directly trust the provider response alone. Instead:
- User clicks “Continue with Google/Microsoft”
- Provider authenticates them
- Your backend verifies the returned tokens
- Your app creates its own session
2) Use the Authorization Code Flow with PKCE
This is the modern standard for browser apps, SPAs, and mobile.
- Safer than implicit flow
- Works well for SaaS
- Recommended by both Google and Microsoft
3) Verify ID tokens server-side
After login:
- Validate signature using the provider’s JWKS
- Check issuer (
iss) - Check audience (
aud) - Check expiration (
exp) - Optionally validate nonce / state
Then map the external identity to your internal user record.
Best implementation options
Option A: Use an auth provider / identity platform
If you want speed and less maintenance:
- Auth0
- Clerk
- WorkOS
- Firebase Auth
- Supabase Auth
- Azure AD B2C / Entra External ID
This is usually best for SaaS unless you have strong reasons to own auth fully.
Option B: Build it yourself
Use:
- OIDC provider SDKs
- Backend session cookies
- Token verification libraries
Choose this if you want maximum control and are comfortable maintaining:
- token validation
- session security
- account linking
- refresh logic
- provider quirks
SaaS-specific considerations
Account linking
A user may sign in with Google one day and Microsoft the next. You should decide whether to:
- create separate accounts, or
- link both identities to one internal user
Usually SaaS apps should support linking by verified email or explicit user action.
Enterprise Microsoft sign-in
If you’ll sell to companies, Microsoft sign-in may mean:
- personal Microsoft accounts
- work/school accounts via Entra ID
Make sure your Microsoft setup supports the account types you want.
Authorization vs authentication
If you also need access to Google Workspace or Microsoft 365 APIs, that’s a separate use case:
- sign-in = OIDC
- API access = OAuth scopes and refresh tokens
Don’t mix them unless needed.
My recommendation
For most SaaS apps:
- Use OIDC Authorization Code Flow with PKCE
- Put an auth provider in front unless you need custom auth logic
- Store your own app session after successful login
- Support account linking and email verification
If you want, I can also recommend the best auth provider for your stack (Next.js, React, Rails, Django, Node, etc.) and whether you should use hosted login or in-app login.