- Add email verification with token-based validation - Integrate Google, Facebook, and Yahoo OAuth providers - Add OAuth configuration and email service modules - Update User model with email_verified, oauth_provider, oauth_id fields - Implement async password hashing/verification to prevent blocking - Add database migration script for new user fields - Create email verification page with professional UI - Update login page with social login buttons (Google, Facebook, Yahoo) - Add OAuth callback token handling - Implement scroll-to-top navigation component - Add 5-second real-time polling for Products and Services pages - Enhance About page with Apple-style scroll animations - Update Home and Contact pages with branding and business info - Optimize API cache with prefix-based clearing - Create comprehensive setup documentation and quick start guide - Fix login performance with ThreadPoolExecutor for bcrypt operations Performance improvements: - Login time optimized to ~220ms with async password verification - Real-time data updates every 5 seconds - Non-blocking password operations Security enhancements: - Email verification required for new accounts - OAuth integration for secure social login - Verification tokens expire after 24 hours - Password field nullable for OAuth users
9.3 KiB
PromptTech Solutions - Authentication Setup Guide
Complete OAuth & Email Verification Implementation
This guide will walk you through setting up Google OAuth, Facebook OAuth, Yahoo OAuth, and Gmail SMTP for email verification.
📋 Table of Contents
- Google OAuth Setup
- Gmail SMTP Setup
- Facebook OAuth Setup
- Yahoo OAuth Setup
- Backend Configuration
- Testing the Implementation
1. Google OAuth Setup
Step 1.1: Create Google Cloud Project
- Go to Google Cloud Console
- Click "Select a project" → "NEW PROJECT"
- Project Name:
PromptTech Solutions - Click "CREATE"
Step 1.2: Enable Google+ API
- In your project, go to APIs & Services → Library
- Search for "Google+ API"
- Click on it and press ENABLE
Step 1.3: Create OAuth 2.0 Credentials
-
Go to APIs & Services → Credentials
-
Click CREATE CREDENTIALS → OAuth client ID
-
If prompted, configure OAuth consent screen first:
- User Type: External
- App name:
PromptTech Solutions - User support email:
prompttechbz@gmail.com - Developer contact:
prompttechbz@gmail.com - Click SAVE AND CONTINUE
- Scopes: Add
.../auth/userinfo.emailand.../auth/userinfo.profile - Click SAVE AND CONTINUE
- Test users: Add your Gmail address
- Click SAVE AND CONTINUE
-
Back to Credentials → CREATE CREDENTIALS → OAuth client ID
- Application type: Web application
- Name:
PromptTech Web Client - Authorized JavaScript origins:
http://localhost:5300http://prompttech.dynns.com:5300https://prompttech.dynns.com(if you have SSL)
- Authorized redirect URIs:
http://localhost:8181/api/auth/google/callbackhttp://prompttech.dynns.com:8181/api/auth/google/callback
- Click CREATE
-
SAVE THESE CREDENTIALS:
- Client ID:
xxxxxxxx-xxxxxxxx.apps.googleusercontent.com - Client Secret:
GOCSPX-xxxxxxxxxxxxxxxxxx
- Client ID:
2. Gmail SMTP Setup (For Email Verification)
Option A: Using Gmail Account (Personal - Recommended for Testing)
- Go to your Gmail account settings
- Click Security (left sidebar)
- Enable 2-Step Verification (if not already enabled)
- After enabling 2FA, go back to Security
- Click App passwords (you'll only see this after enabling 2FA)
- Select app: Mail
- Select device: Other (Custom name)
- Enter:
PromptTech Solutions - Click GENERATE
- SAVE THIS 16-CHARACTER PASSWORD (example:
abcd efgh ijkl mnop)
Important Notes:
- This is NOT your Gmail password
- This is a special app-specific password
- You'll use this in your
.envfile
Option B: Using Google Workspace (Business - Recommended for Production)
If you want a professional email (e.g., no-reply@prompttech.com):
- Sign up for Google Workspace
- Cost: ~$6/month per user
- Benefits: Professional email, no "sent via Gmail" footer
- Create an account like
no-reply@prompttech.com - Follow the same App Password steps as Option A
For now, use Option A (personal Gmail) to test everything.
3. Facebook OAuth Setup
Step 3.1: Create Facebook App
- Go to Facebook Developers
- Click My Apps → Create App
- Select Consumer → Next
- App Name:
PromptTech Solutions - App Contact Email:
prompttechbz@gmail.com - Click Create App
Step 3.2: Configure Facebook Login
- In your app dashboard, click Add Product
- Find Facebook Login → Set Up
- Select Web platform
- Site URL:
http://localhost:5300(for testing) - Click Save → Continue
Step 3.3: Configure OAuth Settings
-
Go to Facebook Login → Settings (left sidebar)
-
Valid OAuth Redirect URIs:
http://localhost:8181/api/auth/facebook/callback http://prompttech.dynns.com:8181/api/auth/facebook/callback -
Click Save Changes
Step 3.4: Get App Credentials
- Go to Settings → Basic (left sidebar)
- SAVE THESE:
- App ID:
1234567890123456 - App Secret: Click Show →
abc123def456ghi789jkl012mno345pq
- App ID:
Step 3.5: Make App Live (Important!)
- At the top of dashboard, toggle from Development to Live
- You may need to complete App Review for full production use
4. Yahoo OAuth Setup
Step 4.1: Create Yahoo App
-
Go to Yahoo Developer Network
-
Sign in with your Yahoo account
-
Click My Apps → Create an App
-
App Name:
PromptTech Solutions -
Application Type: Web Application
-
Home Page URL:
http://localhost:5300 -
Redirect URI(s):
http://localhost:8181/api/auth/yahoo/callback http://prompttech.dynns.com:8181/api/auth/yahoo/callback -
API Permissions: Select OpenID Connect
-
Click Create App
Step 4.2: Get App Credentials
-
After creating the app, you'll see:
- Client ID (Consumer Key):
dj0yJmk9xxxxxxxxxx - Client Secret (Consumer Secret): Click Show →
abcdef123456789
- Client ID (Consumer Key):
-
SAVE THESE CREDENTIALS
5. Backend Configuration
Step 5.1: Update .env File
Create or update /backend/.env with all your credentials:
# JWT Secret (generate a random string)
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
# Email Configuration (Gmail SMTP)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=prompttechbz@gmail.com
SMTP_PASSWORD=abcd efgh ijkl mnop # Your 16-char App Password from Step 2
FROM_EMAIL=prompttechbz@gmail.com
# Frontend URL (where users will be redirected)
FRONTEND_URL=http://localhost:5300
# Google OAuth
GOOGLE_CLIENT_ID=xxxxxxxx-xxxxxxxx.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-xxxxxxxxxxxxxxxxxx
GOOGLE_REDIRECT_URI=http://localhost:8181/api/auth/google/callback
# Facebook OAuth
FACEBOOK_APP_ID=1234567890123456
FACEBOOK_APP_SECRET=abc123def456ghi789jkl012mno345pq
FACEBOOK_REDIRECT_URI=http://localhost:8181/api/auth/facebook/callback
# Yahoo OAuth
YAHOO_CLIENT_ID=dj0yJmk9xxxxxxxxxx
YAHOO_CLIENT_SECRET=abcdef123456789
YAHOO_REDIRECT_URI=http://localhost:8181/api/auth/yahoo/callback
Step 5.2: Install Required Python Packages
cd /media/pts/Website/PromptTech_Solution_Site/backend
pip install authlib httpx python-multipart itsdangerous
These packages are for:
authlib: OAuth libraryhttpx: Async HTTP clientpython-multipart: For form dataitsdangerous: Token generation
Step 5.3: Update Database Model
The User model needs these additional fields (should already be in models.py):
email_verified: Booleanverification_token: String (optional)oauth_provider: String (google, facebook, yahoo, email)
6. Testing the Implementation
Test Email Verification
- Start backend:
cd scripts && ./start_backend.sh - Start frontend:
npm run build(since you're using nginx) - Go to
http://localhost:5300/login - Click "Sign up"
- Fill in:
- First Name: John
- Last Name: Doe
- Email: your-test-email@gmail.com
- Password: test123
- Click "Create Account"
- Check your email for verification link
- Click the verification link
- You should be redirected and logged in
Test Google OAuth
- On login page, click "Sign in with Google"
- Select your Google account
- Grant permissions
- Should redirect back and log you in
Test Facebook OAuth
- On login page, click "Sign in with Facebook"
- Log in to Facebook (if not already)
- Grant permissions
- Should redirect back and log you in
Test Yahoo OAuth
- On login page, click "Sign in with Yahoo"
- Log in to Yahoo account
- Grant permissions
- Should redirect back and log you in
🚨 Important Security Notes
For Production Deployment
-
Change JWT Secret: Generate a strong random key
python -c "import secrets; print(secrets.token_urlsafe(64))" -
Use HTTPS: Update all URLs to
https:// -
Environment Variables: Never commit
.envfile to git -
App Passwords: Store securely, rotate periodically
-
OAuth Scopes: Only request necessary permissions
-
Rate Limiting: Add rate limiting to prevent abuse
-
CORS: Configure properly for production domain
📞 Need Help?
If you encounter issues:
- Check logs:
tail -f backend/logs/*.log - Test email: Send a test email using Python SMTP
- OAuth errors: Check redirect URIs match exactly
- Database: Verify email_verified column exists
✅ Checklist
- Google OAuth configured
- Gmail App Password created
- Facebook App created and live
- Yahoo App created
.envfile updated with all credentials- Python packages installed
- Backend restarted
- Frontend rebuilt
- Tested email registration
- Tested Google login
- Tested Facebook login
- Tested Yahoo login
Next Steps: Once everything is tested and working, we'll add:
- Password reset functionality
- Re-send verification email
- Account deletion
- Social account linking/unlinking
Ready to implement! Follow this guide step by step, and your authentication system will be fully functional.