Your Achievement Management System now has Firebase Google Sign-In fully integrated:
static/js/firebase-init.js- Firebase SDK initialization with Google Authtemplates/home.html- Firebase Sign-In button and configuration injectionapp.py- Backend endpoints for authentication
- Go to Google Cloud Console
- Select your Firebase project
- Navigate to APIs & Services > Credentials
- Look for "OAuth 2.0 Client IDs" > Web application
- Copy the Client ID (format:
123456789-abc.apps.googleusercontent.com)
You'll notice the Google Sign-In button needs your actual Client ID. This is used during authentication.
Current location: The button is already created in templates/home.html but Firebase initialization happens server-side.
Your .env file should have Firebase credentials:
FIREBASE_API_KEY=AIzaSyAxhL77J1VfZJd3rqRyR-AtlPYSnZoXnn4
FIREBASE_AUTH_DOMAIN=task-mate-90eee.firebaseapp.com
FIREBASE_DATABASE_URL=https://task-mate-90eee-default-rtdb.firebaseio.com
FIREBASE_PROJECT_ID=task-mate-90eee
FIREBASE_STORAGE_BUCKET=task-mate-90eee.firebasestorage.app
FIREBASE_MESSAGING_SENDER_ID=112228413597
FIREBASE_APP_ID=1:112228413597:web:9f77d62ecf0478394f6474
FIREBASE_MEASUREMENT_ID=G-YVTN10T1Q2✅ These credentials are loaded from .env (never hardcoded in code)
- Go to Firebase Console
- Select your project
- Go to Authentication > Sign-in method
- Click Google
- Toggle ON
- Save
In Google Cloud Console > APIs & Services > OAuth consent screen:
- Go to APIs & Services > Credentials
- Edit your Web application OAuth credentials
- Add Authorized redirect URIs:
- Development:
http://localhost:5000 - Production:
https://yourdomain.com
- Development:
- In OAuth consent screen, add yourself as a Test user
- Use your Google account email for testing
Frontend (home.html)
↓
[User clicks "Sign in with Google" button]
↓
Firebase SDK (firebase-init.js via CDN)
↓
[Google Authentication Dialog]
↓
[JavaScript sends credentials to backend]
↓
Backend (app.py - /auth/google-login)
↓
[Verify email exists in database]
↓
[Create session + redirect to dashboard]
.env- Contains real credentials (never committed).env.example- Template only (committed to GitHub)firebase_config.py- Loads from environment variablesapp.py- Injects config to templates server-side
- No hardcoded API keys in JavaScript
- Firebase config injected from Flask template
- Only public SDK keys exposed in frontend
- User email verified against database
- Sessions properly managed
- TODO: Add Firebase Admin SDK token verification
-
templates/home.html(lines 1-90+)- Firebase config injection
- Google Sign-In button
- Module script import
-
static/js/firebase-init.js- Firebase SDK initialization
signInWithGoogle()function- Backend communication
-
app.py(lines ~728-790+)POST /auth/google-loginendpointPOST /auth/logoutendpoint- Firebase config passing to templates
-
firebase_config.py- Loading
.envvariables - Config validation
- Loading
# 1. Activate virtual environment
venv1\Scripts\Activate.ps1
# 2. Run Flask app
python app.py
# 3. Navigate to home page
# Open: http://localhost:5000/- You should see "Sign in with Google" button
- Click it → Google OAuth dialog appears
- Sign in with test account → Redirects to student dashboard
- Check Flask logs for
✅messages
✅ Firebase config injected from server
✅ Firebase Google Sign-In initialized
✅ User signed in: user@example.com
✅ Backend authentication successful
| Issue | Solution |
|---|---|
| "invalid_client" error | Check your Google OAuth credentials are correct in Google Cloud |
| Firebase config undefined | Ensure .env file exists with all Firebase fields |
| Sign-in button doesn't work | Check browser console for errors (F12 > Console tab) |
| Email not found in database | Ensure test user's email matches a student record in DB |
| Redirect loop | Check /auth/google-login endpoint in Flask logs |
All required packages should be installed:
pip install -r requirements.txt
# Key packages:
# - Flask
# - Flask-SQLAlchemy
# - python-dotenv (for .env file support)Firebase SDK is loaded via CDN, no npm installation needed for this setup.
When sharing your code:
-
Commit to GitHub:
- ✅
.env.example(shows what keys are needed) - ✅
firebase_config.py - ✅
static/js/firebase-init.js - ✅ Updated
templates/home.html - ❌
.env(in .gitignore - never commits)
- ✅
-
New Developer Setup:
- Clones repo
- Copies
.env.example→.env - Adds their own Firebase credentials
- Gets their own Google OAuth credentials
- Tests locally
- Get your Google OAuth Client ID from Google Cloud Console
- Test the sign-in flow locally
- Verify database integration - ensure test user email exists in
studenttable - Check browser console (F12) for any JavaScript errors
- Review the implementation in provided documentation files:
FIREBASE_SETUP.md- Complete setup guideFIREBASE_IMPLEMENTATION_SUMMARY.md- What was implementedQUICK_REFERENCE.md- Quick reference
FIREBASE_SETUP.md- Step-by-step Firebase project setupFIREBASE_DEVELOPER_COMMENTS.md- Code implementation detailsFIREBASE_IMPLEMENTATION_SUMMARY.md- Full implementation summaryQUICK_REFERENCE.md- API endpoints and config referenceContributing.md- Development guidelines
Your Firebase Google Sign-In integration is ready to test. The system:
✅ Loads credentials securely from .env
✅ Injects config to frontend via Flask
✅ Handles Google authentication flow
✅ Manages user sessions
✅ Redirects authenticated users to dashboard
✅ Never exposes sensitive credentials in code or frontend
Status: Ready for testing and deployment! 🎉