Google authentication has been properly configured in the frontend with the following improvements:
- Updated AuthContext to redirect to
/dashboardafter successful Google login - Added
access_type=offlineandprompt=consentfor better OAuth flow - Proper error handling for network issues
- Enabled PKCE flow for enhanced security
- Set
detectSessionInUrl: trueto properly handle OAuth callbacks - Enabled
autoRefreshTokenfor persistent sessions
- Improved error handling in handleGoogleLogin
- Better async/await pattern
- Shows appropriate error messages if Google auth fails
- Go to Supabase Dashboard → Your Project
- Navigate to Authentication → Providers
- Click Google
- Toggle to Enabled
You need a Google OAuth 2.0 Client ID and Secret:
-
Go to Google Cloud Console
-
Create a new project or select existing one
-
Enable Google+ API
-
Go to Credentials → Create Credentials → OAuth 2.0 Client ID
-
Choose Web application
-
Add authorized redirect URIs:
- For Development:
http://localhost:5173/dashboard - For Development:
http://localhost:5173 - For Production:
https://yourdomain.com/dashboard - For Production:
https://yourdomain.com
- For Development:
-
Copy the Client ID and Client Secret
- In Supabase Dashboard → Authentication → Google Provider
- Paste:
- Client ID (from Google Cloud)
- Client Secret (from Google Cloud)
- Click Save
In Supabase Dashboard → Authentication → URL Configuration:
-
Set Site URL to your application URL:
- Development:
http://localhost:5173 - Production:
https://yourdomain.com
- Development:
-
Add Redirect URLs:
http://localhost:5173/dashboardhttp://localhost:5173/https://yourdomain.com/dashboardhttps://yourdomain.com/
-
Click Save
-
Make sure you have the correct
.envvariables:VITE_SUPABASE_URL=https://your-project.supabase.co VITE_SUPABASE_ANON_KEY=your-anon-key -
Run the dev server:
cd frontend npm run dev -
Navigate to
http://localhost:5173/login -
Click "Continue with Google"
-
You'll be redirected to Google's login page
-
After successful login, you'll be redirected back to
/dashboard
- Solution: Make sure the redirect URLs in Google Cloud Console match exactly those in Supabase URL Configuration
- Include both with and without
/dashboard
- Solution: Check that
detectSessionInUrl: trueis set in Supabase client initialization - Clear browser cache and local storage
- Check browser console for detailed error messages
- Solution: The auth state listener in AuthContext should catch the OAuth session
- Check that
onAuthStateChangeis properly set up - Verify session is being loaded with
getSession()
- Solution:
- Check network tab in browser DevTools for errors
- Verify Client ID and Secret are correct in Supabase
- Check that your app domain is added to Google OAuth consent screen
- ✅ Using PKCE flow (more secure than implicit)
- ✅ Using
offlineaccess type for refresh tokens - ✅ Using
consentprompt to ensure user grants permissions - ✅ Proper error handling and validation
- ✅ Sessions are persisted with autoRefreshToken