OAuth

OAuth is a protocol that lets users sign into your app using their existing accounts from services like Google, GitHub, or Apple — without sharing their passwords with you. It delegates authentication to a trusted provider, reducing friction for users and security responsibility for developers.

Example

Instead of creating a new account with email and password, a user clicks 'Sign in with Google.' Google confirms their identity and sends your app a token. The user is logged in without ever giving you their Google password.

OAuth is why you see "Sign in with Google" buttons everywhere. It's easier for users and safer for developers.

How OAuth Works

  1. User clicks "Sign in with Google" on your app
  2. Redirected to Google — Google shows a consent screen
  3. User approves — Grants your app access to basic info
  4. Google redirects back — Sends an authorization code to your app
  5. Your app exchanges code for tokens — Gets user info from Google
  6. User is logged in — Account created or matched automatically

Why Use OAuth?

BenefitExplanation
No passwords to manageThe provider handles password security
Less frictionUsers don't need to create yet another account
Verified emailsProvider confirms the email is real
Trusted experienceUsers are familiar with social login

Common OAuth Providers

  • Google — Most widely used
  • GitHub — Popular for developer tools
  • Apple — Required for iOS apps with social login
  • Discord — Popular for community-focused apps

Implementing OAuth

Don't build OAuth from scratch. Use auth libraries:

  • Better Auth — Built-in social login support
  • Auth.js (NextAuth) — Multiple providers with minimal config
  • Clerk — Managed auth with social login built in

OAuth Tips for Vibe Coders

  1. Start with Google — Covers the most users
  2. Add GitHub — If your audience is developers
  3. Keep email/password as fallback — Not everyone uses social login
  4. Request minimal permissions — Only ask for what you need