Add secure Google authentication to your SaaS application
Google OAuth allows users to sign in to your app using their Google account. This provides:

💡 Tip: You can publish your app later for production use. For development, "External" with testing mode is sufficient.
http://localhost:3000 (for development)https://yourdomain.com (for production)http://localhost:3000/api/auth/callback/googlehttps://yourdomain.com/api/auth/callback/google⚠️ Important: Make sure the redirect URI exactly matches your app's callback URL, including the protocol (http/https).
After creating the OAuth client, you'll see a modal with your credentials:
Client ID: 123456789-abcdefghijklmnop.apps.googleusercontent.com Client Secret: GOCSPX-1234567890abcdefghij
Add your Google OAuth credentials to your project's environment variables:
.env.local file# Google OAuth GOOGLE_CLIENT_ID=your_client_id_here GOOGLE_CLIENT_SECRET=your_client_secret_here NEXTAUTH_URL=http://localhost:3000 NEXTAUTH_SECRET=your_random_secret_min_32_chars
💡 Tip: Generate a secure NEXTAUTH_SECRET using: openssl rand -base64 32
npm run devhttp://localhost:3000✅ Success: If you see your name and avatar, Google OAuth is working correctly!
The redirect URI in your Google Cloud Console doesn't match your app's callback URL.
Solution: Double-check that the redirect URI in Google Cloud Console exactly matches http://localhost:3000/api/auth/callback/google
Your app hasn't been verified by Google yet.
Solution: Click "Advanced" → "Go to [your app] (unsafe)" during development. For production, submit your app for verification.
Your Client ID or Client Secret is incorrect.
Solution: Verify that you copied the credentials correctly from Google Cloud Console to your .env.local file.