OAuth Providers Setup
Complete guide to configuring OAuth authentication with Google, Facebook, GitHub, and HuggingFace for Open Navigator.
Overviewโ
This application supports four OAuth providers for user authentication:
- ๐ต Google - Google Account authentication
- ๐ต Facebook - Facebook Login
- โซ GitHub - GitHub OAuth Apps
- ๐ค HuggingFace - HuggingFace OAuth
Each provider requires creating an OAuth application and configuring redirect URIs. Never commit secrets to git!
๐ Required Redirect URIsโ
For all providers, you need to configure these redirect URIs:
Local Developmentโ
http://localhost:8000/auth/callback/{provider}
Production (HTTPS required)โ
https://www.communityone.com/auth/callback/{provider}
https://your-space-name.hf.space/auth/callback/{provider}
Replace {provider} with: google, facebook, github, or huggingface
๐ต Google OAuth Setupโ
Step 1: Create Google Cloud Projectโ
- Go to Google Cloud Console
- Click "Select a project" โ "NEW PROJECT"
- Enter project name:
open-navigator-for-engagement - Click "CREATE"
Step 2: Enable Google Identity Toolkit APIโ
- Navigate to APIs & Services โ Library
- Search for:
Google Identity Toolkit API - Click "ENABLE"
Step 3: Configure OAuth Consent Screenโ
-
Go to APIs & Services โ OAuth consent screen
-
Select "External" user type โ Click "CREATE"
-
Fill in app information:
- App name:
Open Navigator - User support email: Your email
- App domain:
www.communityone.com - Developer contact: Your email
- App name:
-
Click "SAVE AND CONTINUE"
-
Scopes page:
- Click "ADD OR REMOVE SCOPES"
- Select:
userinfo.email,userinfo.profile,openid - Click "UPDATE" โ "SAVE AND CONTINUE"
-
Test users (optional for development):
- Add your Google account email
- Click "SAVE AND CONTINUE"
Step 4: Create OAuth Credentialsโ
-
Go to APIs & Services โ Credentials
-
Click "+ CREATE CREDENTIALS" โ "OAuth client ID"
-
Configure:
- Application type: Web application
- Name:
Open Navigator Web App
-
Authorized JavaScript origins:
http://localhost:5173http://localhost:8000https://www.communityone.comhttps://your-space.hf.space -
Authorized redirect URIs:
http://localhost:8000/auth/callback/googlehttps://www.communityone.com/auth/callback/googlehttps://your-space.hf.space/auth/callback/google -
Click "CREATE"
-
Copy your credentials (you'll need these for environment variables):
- Client ID:
[long string].apps.googleusercontent.com - Client Secret:
GOCSPX-[random string]
- Client ID:
Step 5: Add to Environment Variablesโ
Local (.env):
GOOGLE_CLIENT_ID=your-client-id-here.apps.googleusercontent.com
GOOGLE_CLIENT_SECRET=GOCSPX-your-secret-here
HuggingFace Spaces:
- Go to Space Settings โ Variables and secrets
- Add as Repository secrets (not variables)
๐ต Facebook OAuth Setupโ
Step 1: Create Facebook Appโ
- Go to Facebook Developers
- Click "Create App"
- Choose "Other" โ "Next" โ "Consumer" โ "Next"
- Enter details:
- App name:
Open Navigator - Contact email: Your email
- App name:
- Click "Create App"
Step 2: Add Facebook Login Productโ
- In app dashboard, find "Add Products"
- Find "Facebook Login" โ Click "Set Up"
- Choose "Web" platform
- Enter site URL:
http://localhost:5173 - Click "Save" โ "Continue"
Step 3: Configure OAuth Settingsโ
-
Left sidebar: Click "Use cases โ Authentication and account creation โ Customize"
OR: "Facebook Login โ Settings"
-
Valid OAuth Redirect URIs (one per line):
http://localhost:8000/auth/callback/facebookhttps://www.communityone.com/auth/callback/facebookhttps://your-space.hf.space/auth/callback/facebook -
Enable these settings:
- โ Client OAuth Login: ON
- โ Web OAuth Login: ON
- โ Native or desktop app: OFF
-
Click "Save Changes"
Step 4: Configure App Settingsโ
-
Left sidebar: Click "App settings โ Basic"
-
App Domains:
localhostwww.communityone.comyour-space.hf.space -
Privacy Policy URL:
https://www.communityone.com/privacyfacebook.html -
Click "Save Changes"
Step 5: Get App Credentialsโ
- Still in "App settings โ Basic"
- Copy your credentials:
- App ID: 15-digit number
- App Secret: Click "Show" โ 32-character string
Step 6: Add to Environment Variablesโ
Local (.env):
FACEBOOK_APP_ID=your-app-id-here
FACEBOOK_APP_SECRET=your-app-secret-here
HuggingFace Spaces:
- Add as Repository secrets
Step 7: App Modeโ
Development Mode (default):
- Only you can log in
- Good for testing
Live Mode (for production):
- Requires App Review
- Toggle in "App settings โ Basic"
โซ GitHub OAuth Setupโ
Step 1: Create OAuth Appโ
- Go to GitHub Settings โ Developer settings
- Click "OAuth Apps" โ "New OAuth App"
Step 2: Configure Applicationโ
-
Fill in details:
- Application name:
Open Navigator - Homepage URL:
https://www.communityone.com - Authorization callback URL:
http://localhost:8000/auth/callback/github
- Application name:
-
Click "Register application"
Step 3: Add Additional Callback URLsโ
GitHub only allows ONE callback URL per OAuth app. For multiple environments:
Option 1: Create separate apps for each environment
- Local Dev app โ
http://localhost:8000/auth/callback/github - Production app โ
https://www.communityone.com/auth/callback/github
Option 2: Use production URL only
- Set:
https://www.communityone.com/auth/callback/github - For local dev, temporarily change to localhost during testing
Step 4: Get Credentialsโ
-
On the OAuth app page:
- Client ID: 20-character string
- Client secrets: Click "Generate a new client secret"
-
Copy both values immediately (secret won't be shown again)
Step 5: Add to Environment Variablesโ
Local (.env):
GITHUB_CLIENT_ID=your-client-id-here
GITHUB_CLIENT_SECRET=your-client-secret-here
HuggingFace Spaces:
- Add as Repository secrets
๐ค HuggingFace OAuth Setupโ
Step 1: Create OAuth Applicationโ
- Go to HuggingFace Settings โ Applications
- Click "Create a new application"
Step 2: Configure Applicationโ
-
Fill in details:
- Application name:
Open Navigator - Homepage URL:
https://www.communityone.com - Scopes:
openid profile email
- Application name:
-
Redirect URIs (add all):
http://localhost:8000/auth/callback/huggingfacehttps://www.communityone.com/auth/callback/huggingfacehttps://your-space.hf.space/auth/callback/huggingface -
Click "Create application"
Step 3: Get Credentialsโ
-
On the application page:
- Client ID: UUID format (8-4-4-4-12 characters)
- Client Secret: Long random string starting with
oauth_app_secret_
-
Copy both values
Step 4: Add to Environment Variablesโ
Local (.env):
HUGGINGFACE_CLIENT_ID=your-client-id-here
HUGGINGFACE_CLIENT_SECRET=oauth_app_secret_your-secret-here
HuggingFace Spaces:
- Add as Repository secrets
๐ Environment Variables Referenceโ
Local Development (.env)โ
Create a .env file in the project root:
# Database
DATABASE_URL=sqlite:///./data/users.db
# JWT Secret (generate with: openssl rand -hex 32)
JWT_SECRET_KEY=your-random-32-byte-hex-string
# Application URLs
FRONTEND_URL=http://localhost:5173
API_BASE_URL=http://localhost:8000
# Google OAuth
GOOGLE_CLIENT_ID=
GOOGLE_CLIENT_SECRET=
# Facebook OAuth
FACEBOOK_APP_ID=
FACEBOOK_APP_SECRET=
# GitHub OAuth
GITHUB_CLIENT_ID=
GITHUB_CLIENT_SECRET=
# HuggingFace OAuth
HUGGINGFACE_CLIENT_ID=
HUGGINGFACE_CLIENT_SECRET=
Never commit .env to git! It's already in .gitignore.
Production (HuggingFace Spaces)โ
Add these as Repository secrets in Space Settings โ Variables and secrets:
# CRITICAL: Use HTTPS for production URLs
API_BASE_URL=https://www.communityone.com
FRONTEND_URL=https://www.communityone.com
# Database
DATABASE_URL=sqlite:///./data/users.db
# JWT Secret (same as local for consistency, or generate new)
JWT_SECRET_KEY=your-random-32-byte-hex-string
# OAuth Credentials (same as local)
GOOGLE_CLIENT_ID=...
GOOGLE_CLIENT_SECRET=...
FACEBOOK_APP_ID=...
FACEBOOK_APP_SECRET=...
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...
HUGGINGFACE_CLIENT_ID=...
HUGGINGFACE_CLIENT_SECRET=...
Production URLs MUST use https:// - OAuth providers reject http:// for security.
๐งช Testing OAuth Configurationโ
Local Testingโ
-
Start all services:
./start-all.sh -
Open application: http://localhost:5173
-
Test each provider:
- Click "Login" โ Select provider
- Authorize the app
- Should redirect back with your profile
-
Check for errors in:
- Browser console (F12)
- API server logs
- Network tab (watch redirect flow)
Production Testingโ
-
Deploy to HuggingFace Spaces (see HuggingFace Deployment Guide)
-
Add all environment secrets in Space settings
-
Test each provider at https://www.communityone.com
-
Common issues:
- โ 400 Bad Request โ Redirect URI not registered
- โ redirect_uri_mismatch โ Using
http://instead ofhttps:// - โ 401 Unauthorized โ Wrong client secret or missing env vars
๐ง Troubleshootingโ
"Redirect URI Mismatch"โ
Cause: OAuth provider doesn't recognize the callback URL
Fix:
- Check exact URL in error message
- Add that exact URL to provider settings
- Ensure
http://vshttps://matches - No trailing slashes
"Invalid Client"โ
Cause: Wrong client ID or secret
Fix:
- Verify credentials copied correctly
- Check for extra spaces
- Ensure environment variables are loaded
- Restart server after changing
.env
"Access Blocked"โ
Cause: App not verified or in development mode
Fix:
- Google: Add yourself as test user in OAuth consent screen
- Facebook: Use Development Mode for testing
- GitHub: No verification needed
- HuggingFace: No verification needed
Production HTTPS Issuesโ
Cause: Using http:// URLs in production
Fix:
# In HuggingFace Spaces secrets, use HTTPS:
API_BASE_URL=https://www.communityone.com # โ
Correct
API_BASE_URL=http://www.communityone.com # โ Wrong
๐ Related Documentationโ
- Authentication Setup - Database and JWT configuration
- HuggingFace Deployment - Deploy to production
- Environment Configuration - Full environment setup
๐ Security Best Practicesโ
- Never commit secrets - Use
.envfiles (gitignored) - Use HTTPS in production - Required by OAuth providers
- Rotate secrets regularly - Generate new secrets periodically
- Limit OAuth scopes - Only request necessary permissions
- Use separate apps - Different OAuth apps for dev/staging/prod
- Monitor usage - Check OAuth app dashboards for suspicious activity
๐ Quick Referenceโ
| Provider | Setup URL | Redirect URI Format |
|---|---|---|
| console.cloud.google.com | /auth/callback/google | |
| developers.facebook.com | /auth/callback/facebook | |
| GitHub | github.com/settings/developers | /auth/callback/github |
| HuggingFace | huggingface.co/settings/applications | /auth/callback/huggingface |
Start with one provider (e.g., Google) to verify the flow works, then add others incrementally.