Google OAuth

Sign in with Google via Laravel Socialite. This guide walks you through creating OAuth credentials in Google Cloud Console.

Good to know

Google OAuth is optional. If removed via CLI, email/password authentication still works. You can always add it back later by re-running npx stacktura init from a clean copy.

Setup Guide

Create a Google Cloud project

Go to console.cloud.google.com, click Select a project > New project, give it a name and create it.

Configure the OAuth consent screen

In the left sidebar, go to APIs & Services > OAuth consent screen.

  • User type: External
  • App name: your app name
  • User support email: your email
  • Scopes: add email and profile
  • Test users: add your own email (while in testing mode)

Create OAuth credentials

Go to APIs & Services > Credentials > Create Credentials > OAuth client ID.

  • Application type: Web application
  • Name: anything (e.g. "Stacktura Web")
  • Authorized redirect URIs (add both):
    • http://localhost:8000/api/auth/google/callback (local)
    • https://api.yourdomain.com/api/auth/google/callback (production)

Copy your credentials

After creation, copy the Client ID and Client secret into backend/.env:

GOOGLE_CLIENT_ID=xxxxxxxxxxxxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-xxxxxxxxxxxxx

Test it

Restart your backend (docker compose restart backend), then click "Sign in with Google" on the login page. You should be redirected to Google's consent screen and back.


Common Issues

Redirect URI mismatch

The redirect URI must match exactly. No trailing slash, correct port, correct protocol. localhost and 127.0.0.1 are treated as different origins by Google.

Access blocked: app has not completed verification

Your app is still in Testing mode. Either add your email to test users or publish the app. For production, you need to submit for Google verification.

Account linking

If a user registers with email first and later signs in with Google using the same email, Stacktura links both accounts automatically. No duplicate accounts.


Going to Production

  1. In Google Cloud Console, go to OAuth consent screen > Publish App
  2. Submit for verification if you use sensitive scopes (email/profile are usually auto-approved)
  3. Add your production redirect URI to the OAuth credentials
  4. Update GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET in your production .env
Billing (Stripe) Admin Dashboard

Documentation

Ready to build your SaaS?

Full source code, all modules, lifetime updates.

Get Stacktura — $249