- Google Cloud Console account
- Node.js and npm installed
- MongoDB database running
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Google+ API:
- Go to "APIs & Services" > "Library"
- Search for "Google+ API" and enable it
- Create OAuth 2.0 credentials:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth 2.0 Client IDs"
- Choose "Web application"
- Add authorized JavaScript origins:
http://localhost:5173(for development)https://yourdomain.com(for production)
- Add authorized redirect URIs:
http://localhost:5173(for development)https://yourdomain.com(for production)
- Copy the Client ID
- Replace
YOUR_GOOGLE_CLIENT_IDinclient/src/main.jsxwith your actual Google Client ID:
<GoogleOAuthProvider clientId="your-actual-google-client-id-here">-
Navigate to the Server directory:
cd Server -
Install dependencies:
npm install
-
Start the server:
npm start
-
Navigate to the client directory:
cd client -
Start the development server:
npm run dev
- ✅ Google authentication buttons in navbar
- ✅ Google login/signup on Login page
- ✅ Google login/signup on Signup page
- ✅ Google OAuth provider setup
- ✅ Custom Google login component
- ✅ Google authentication endpoint (
/api/auth/google) - ✅ Updated User model with Google fields
- ✅ Google user creation and login logic
- ✅ JWT token generation for Google users
- User clicks "Continue with Google" button
- Google OAuth popup opens
- User authenticates with Google
- Frontend receives Google credentials
- Frontend sends user data to backend
- Backend creates/updates user in database
- Backend returns JWT token
- Frontend stores user session and redirects
- ✅ Email validation
- ✅ JWT token authentication
- ✅ Secure password hashing (for non-Google users)
- ✅ Google ID verification
- ✅ User session management
Make sure to set these environment variables in your backend:
JWT_SECRET=your-secret-key-here
MONGODB_URI=your-mongodb-connection-string- Start both frontend and backend servers
- Navigate to
http://localhost:5173 - Click "Login" or "Sign Up"
- Click "Continue with Google"
- Complete Google authentication
- Verify user is logged in and redirected
- "Invalid Client ID": Make sure you've replaced
YOUR_GOOGLE_CLIENT_IDwith your actual Google Client ID - "Origin not allowed": Add
http://localhost:5173to authorized origins in Google Cloud Console - "Database connection error": Ensure MongoDB is running and connection string is correct
- "JWT_SECRET not set": Set the JWT_SECRET environment variable in your backend