This guide will walk you through setting up Google OAuth for SubZero.
QuitInbox uses OAuth 2.0 with PKCE (Proof Key for Code Exchange) and "Desktop app" client type for truly secret-less authentication. This is specifically designed for public clients like SPAs and PWAs.
Google has two OAuth client types:
| Client Type | Requires Secret? | Use Case |
|---|---|---|
| Desktop app ✅ | NO | Perfect for open source, SPAs, mobile apps |
| Web application ❌ | YES | Requires secret even with PKCE |
We use "Desktop app" type - no secrets needed at all!
✅ Truly secret-less OAuth - Nothing sensitive in your JavaScript bundle!
Why this is secure:
- PKCE cryptographic protection - Each auth request has a unique code challenge that cannot be intercepted
- No secrets to steal - Desktop app clients don't use secrets at all
- Redirect URI validation - Google strictly validates where tokens can be sent (see step 4 below)
- Industry standard - Same model as mobile apps and Electron apps
- Perfect for open source - Users can verify no secrets in code
The client_id is meant to be public - it just identifies your app to Google.
- Go to Google Cloud Console
- Click "Select a project" → "New Project"
- Enter a project name (e.g., "SubZero Gmail Client")
- Click "Create"
- In your project, go to APIs & Services > Library
- Search for "Gmail API"
- Click on "Gmail API"
- Click Enable
- Go to APIs & Services > OAuth consent screen
- Select External user type (unless you have a Google Workspace)
- Click Create
- Fill in the required fields:
- App name: SubZero
- User support email: Your email
- Developer contact email: Your email
- Click Save and Continue
- On the "Scopes" page, click Add or Remove Scopes
- Add these scopes:
https://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/gmail.modify(optional)https://www.googleapis.com/auth/gmail.send(optional)
- Click Update → Save and Continue
- Add test users (your email address)
- Click Save and Continue → Back to Dashboard
- Go to APIs & Services > Credentials
- Click Create Credentials > OAuth client ID
- IMPORTANT: Select "Desktop app" as the application type (NOT "Web application")
- Enter a name: "QuitInbox Desktop Client"
- Click Create
- Copy the Client ID (no secret needed!)
Important Notes:
- Desktop app clients don't have redirect URI restrictions in Google Console
- The redirect URI is validated by the
redirect_uriparameter in the OAuth request - You don't need to add
http://localhost:5173anywhere - it will work automatically - For production, you can use the same client ID - just make sure your app's redirect_uri parameter matches your domain
Create a .env file in your project root:
cp .env.example .envEdit .env and add your client ID:
VITE_GOOGLE_CLIENT_ID=123456789.apps.googleusercontent.comNote: You only need the client_id. Do NOT add client_secret - PKCE doesn't use it!
-
Start the development server:
npm run dev
-
Click "Sign in with Google"
-
You should see the Google OAuth consent screen
-
Grant the requested permissions
-
You should be redirected back to SubZero
Cause: The redirect URI doesn't exactly match what's configured in Google Cloud Console.
Solution:
- Check that the redirect URI in Google Cloud Console exactly matches your app's URL
- For development:
http://localhost:5173/oauth/callback - No trailing slashes
- Port number must match
Cause: The VITE_GOOGLE_CLIENT_ID environment variable is not set.
Solution:
- Make sure you've created a
.envfile - Verify the client ID is correctly copied
- Restart the dev server after changing
.env
Cause: OAuth consent screen not properly configured or missing scopes.
Solution:
- Complete the OAuth consent screen configuration
- Make sure all required scopes are added
- Add your email as a test user
Cause: Your app is in testing mode and not verified by Google.
Solution: This is expected during development. Click "Advanced" → "Go to SubZero (unsafe)" to proceed. For production, you'll need to submit your app for verification.
When deploying to production:
-
Update OAuth Redirect URIs in Google Cloud Console:
- Add your production domain's JavaScript origin
- Add your production domain's callback URI
-
Set Environment Variable in your hosting platform:
VITE_GOOGLE_CLIENT_ID(that's all you need!)
-
Consider App Verification:
- For public use, submit your app for Google verification
- This removes the "unverified app" warning for users
-
Security Considerations:
- ✅ PKCE provides security without secrets
- ✅ Ensure your redirect URIs are strictly configured
- ✅ Monitor API usage in Google Cloud Console
- ✅ Only authorized redirect URIs can receive tokens
With PKCE, you don't need a backend to "protect" secrets:
- No secret exists - PKCE uses cryptographic challenge/response
- Simpler architecture - Pure frontend, no server costs
- Better privacy - All data stays in the user's browser
- Fully open source - Users can verify no data is sent to your servers
This is the recommended approach for public clients and is more secure than trying to "hide" a client secret in a backend.