This guide will walk you through setting up Google OAuth for the OpenChat application.
- A Google account
- Access to Google Cloud Console
- OpenChat project running locally
- Go to Google Cloud Console
- Create a new project or select an existing one
- Enable the Google+ API (Legacy) or Google Identity API
- Navigate to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth 2.0 Client IDs"
- Configure the OAuth consent screen if prompted
- Choose "Web application" as the application type
- Add authorized redirect URIs:
http://localhost:5174/auth/callback(for development)- Your production callback URL (for production)
-
Copy
.env.exampleto.env.local:cp .env.example .env.local
-
Update
.env.localwith your Google OAuth credentials:VITE_GOOGLE_CLIENT_ID=your_actual_client_id_here VITE_GOOGLE_CLIENT_SECRET=your_actual_client_secret_here
If using Supabase for authentication:
- Go to your Supabase project dashboard
- Navigate to Authentication > Settings
- Add Google as an OAuth provider
- Enter your Google Client ID and Secret
- Add the callback URL:
https://your-supabase-project.supabase.co/auth/v1/callback
-
Start your development server:
npm run dev
-
Navigate to the login page
-
Click "Sign in with Google"
-
Verify the OAuth flow works correctly
- Never commit
.env.localto version control - Keep your Client Secret secure and rotate it regularly
- Use different credentials for development and production
- Regularly review your OAuth consent screen and permissions
- Redirect URI mismatch: Ensure the callback URL in Google Cloud Console matches your app
- Invalid client: Double-check your Client ID and Secret
- OAuth consent screen: Make sure it's properly configured for your app
redirect_uri_mismatch: Add the correct callback URL to your Google OAuth settingsinvalid_client: Verify your credentials are correct and the project is active
For production:
- Create separate OAuth credentials for your production domain
- Update redirect URIs to match your production URL
- Set environment variables in your hosting platform
- Test thoroughly before going live