Documentation Index
Fetch the complete documentation index at: https://mintlify.com/Jesus-Puertos/h-ayuntamiento/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The application supports OAuth authentication through Supabase, allowing users to sign in with Google or Facebook. This guide covers the complete setup process for both providers.For the MVP, email/password authentication is already functional. OAuth is optional but provides a better user experience.
Google OAuth Setup
Set up Google OAuth to allow users to sign in with their Google accounts.Create Google Cloud Project
- Go to console.cloud.google.com
- Create a new project or select an existing one
- Name it something like “Zongolica Turismo”
Configure OAuth Consent Screen
- Navigate to APIs & Services → OAuth consent screen
- Select External user type
- Click Create
- Fill in required information:
- App name: Ayuntamiento de Zongolica
- User support email: Your support email
- Developer contact: Your email
- Click Save and Continue
- Skip adding scopes (default is sufficient)
- Add test users if needed for development
- Click Save and Continue
Create OAuth 2.0 Credentials
- Go to Credentials in the left sidebar
- Click Create Credentials → OAuth client ID
- Select Web application
- Name: “Zongolica Web App”
- Add Authorized JavaScript origins:
- Add Authorized redirect URIs:
(Get your project ref from Supabase Settings → API)
- Click Create
Copy Credentials
Google will show your:
- Client ID:
123456789-abc.apps.googleusercontent.com - Client Secret:
GOCSPX-abc123...
Google OAuth Scopes
By default, the application requests these scopes:email- User’s email addressprofile- Basic profile information (name, picture)
Facebook OAuth Setup
Set up Facebook OAuth to allow users to sign in with Facebook.Create Facebook App
- Go to developers.facebook.com
- Click My Apps → Create App
- Choose Consumer as app type
- Click Next
Configure App Details
- Display Name: Ayuntamiento de Zongolica
- App Contact Email: Your support email
- Click Create App
Add Facebook Login Product
- In the app dashboard, find Facebook Login
- Click Set Up
- Choose Web platform
- Enter your site URL:
https://your-domain.com - Click Save
Configure OAuth Redirect URIs
- Go to Facebook Login → Settings
- In Valid OAuth Redirect URIs, add:
- Click Save Changes
Copy App Credentials
- Go to Settings → Basic
- Copy your App ID:
123456789012345 - Click Show on App Secret and copy it
Configure in Supabase
- Go to your Supabase project
- Navigate to Authentication → Providers
- Find Facebook and click to configure
- Enable the provider ✅
- Paste your App ID (as Client ID)
- Paste your App Secret (as Client Secret)
- Click Save
Facebook OAuth Scopes
The application requests:email- User’s email addresspublic_profile- Name and profile picture
Configure Redirect URIs
Ensure your redirect URIs are configured correctly in both OAuth providers and Supabase.Development URLs
For local development:Production URLs
For your deployed site:Update Supabase Site URL
Test Authentication Flow
Verify that OAuth is working correctly.Click OAuth Button
- Click the onboarding trigger
- Click “Continue with Google” or “Continue with Facebook”
Complete OAuth Flow
- You should be redirected to Google/Facebook
- Authorize the application
- You should be redirected back to your app
- You should see the onboarding continue as an authenticated user
Handle Authentication in Code
The application includes authentication utilities insrc/lib/supabase.ts:
Authentication Callback Page
The callback handler is atsrc/pages/auth/callback.astro:
The callback page exchanges the OAuth code for a session token and redirects users back to the application.
Troubleshooting
”Redirect URI mismatch” Error
Cause: The redirect URI doesn’t match what’s configured in Google Cloud Console Solution:- Check the exact URI in the error message
- Ensure it’s added to Authorized redirect URIs in Google Cloud
- Ensure it matches the Supabase callback URL exactly
OAuth Window Closes Immediately
Cause: Pop-up blockers or incorrect configuration Solution:- Allow pop-ups for your site
- Verify OAuth credentials are correct in Supabase
- Check browser console for error messages
”App Not Verified” Warning (Google)
Cause: Google shows this for apps not yet verified Solution:- For development: Click “Advanced” → “Go to [app name] (unsafe)”
- For production: Complete Google’s app verification process
Facebook Login Not Working in Production
Cause: App is still in development mode Solution:- Go to Facebook App Settings
- Switch App Mode to Live
- Complete any required app review steps
Users Not Being Created in Database
Cause: RLS policies preventing writes Solution:- Verify you ran the complete
supabase-setup.sqlscript - Check that RLS policies are configured
- Ensure user is authenticated before database operations
Security Best Practices
✅ Do:- Use HTTPS in production (required for OAuth)
- Keep OAuth secrets secure and never commit them
- Use environment variables for credentials
- Validate redirect URIs strictly
- Implement CSRF protection (handled by Supabase)
- Expose OAuth secrets in client-side code
- Use HTTP for OAuth in production
- Add wildcard redirect URIs
- Share OAuth credentials between environments
Multiple Environments
Manage OAuth for different environments:Development
- Use separate OAuth app for development
- Add
http://localhost:4321to redirect URIs - Use test accounts
Staging
- Create staging OAuth apps
- Use staging domain in redirect URIs
- Limit to team members
Production
- Use production OAuth apps
- Production domain only
- Complete app verification processes
- Enable all necessary scopes
Next Steps
After configuring OAuth:- Test the authentication flow
- Deploy to production
- Update OAuth redirect URIs with production URLs
- Test production authentication
- Complete app verification for Google (if needed)
- Switch Facebook app to Live mode
