OAuth Configuration for Auth Service
This guide explains how to configure OAuth providers (GitHub and Google) for the auth.do.dev unified authentication service.
Required Environment Variables
Add these to your Convex dashboard for the auth deployment (dependable-pika-747):
# Resend (Email OTP)
RESEND_API_KEY=re_xxxxxxxxxxxx
AUTH_RESEND_FROM=auth@notifications.do.dev
# GitHub OAuth
AUTH_GITHUB_ID=xxxxxxxxxxxx
AUTH_GITHUB_SECRET=xxxxxxxxxxxx
# Google OAuth
AUTH_GOOGLE_ID=xxxxxxxxxxxx.apps.googleusercontent.com
AUTH_GOOGLE_SECRET=xxxxxxxxxxxx
# JWT Secret (generate a random string)
JWT_SECRET=your-random-jwt-secret-string-hereGitHub OAuth Setup
- Go to GitHub Settings > Developer settings > OAuth Apps
- Click "New OAuth App"
- Fill in the application details:
- Application name: do.dev Auth
- Homepage URL: https://auth.do.dev (or http://localhost:3030 for dev)
- Authorization callback URL:
- Development:
http://localhost:3030/api/auth/callback/github - Production:
https://auth.do.dev/api/auth/callback/github
- Development:
- Click "Register application"
- Copy the Client ID and generate a new Client Secret
- Add to Convex environment variables:
AUTH_GITHUB_ID= Your Client IDAUTH_GITHUB_SECRET= Your Client Secret
Google OAuth Setup
- Go to Google Cloud Console
- Create a new project or select existing
- Enable the Google+ API
- Go to "Credentials" and click "Create Credentials" > "OAuth client ID"
- Configure the OAuth consent screen first if prompted
- For Application type, choose "Web application"
- Add authorized JavaScript origins:
http://localhost:3030(development)https://auth.do.dev(production)
- Add authorized redirect URIs:
http://localhost:3030/api/auth/callback/google(development)https://auth.do.dev/api/auth/callback/google(production)
- Click "Create"
- Copy the Client ID and Client Secret
- Add to Convex environment variables:
AUTH_GOOGLE_ID= Your Client IDAUTH_GOOGLE_SECRET= Your Client Secret
Resend Email Setup
- Sign up for Resend
- Verify your domain (do.dev)
- Create an API key
- Add to Convex environment variables:
RESEND_API_KEY= Your API keyAUTH_RESEND_FROM= Your verified sender email (e.g., auth@notifications.do.dev)
JWT Secret Generation
Generate a secure random string for JWT signing:
# Using OpenSSL
openssl rand -base64 32
# Using Node.js
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"Add the generated string as JWT_SECRET in Convex environment variables.
Setting Environment Variables in Convex
- Go to the Convex dashboard
- Select your auth project (dependable-pika-747)
- Go to Settings > Environment Variables
- Add each variable listed above
- Save the changes
Testing OAuth Providers
Development Testing
-
Start the auth service:
cd apps/webs/auth pnpm dev -
Visit http://localhost:3030
-
Try signing in with each provider
-
Check the Convex dashboard logs for any errors
Production Testing
After deploying to production:
- Visit https://auth.do.dev
- Test each OAuth provider
- Verify the redirect flow works correctly
- Check that sessions are created properly
Troubleshooting
GitHub OAuth Issues
- Error: Redirect URI mismatch: Ensure the callback URL in GitHub matches exactly
- Error: Invalid client: Check that CLIENT_ID and CLIENT_SECRET are correct
- 403 Forbidden: Make sure the OAuth app is not in private mode
Google OAuth Issues
- Error: redirect_uri_mismatch: Add all possible redirect URIs in Google Console
- Error: invalid_client: Verify CLIENT_ID format (should end with .apps.googleusercontent.com)
- Access blocked: Complete the OAuth consent screen configuration
Email OTP Issues
- Emails not sending: Verify domain in Resend dashboard
- From address not accepted: Use a verified domain email
- Rate limiting: Check Resend dashboard for quota limits
Security Best Practices
- Never commit secrets: Keep all OAuth credentials in environment variables
- Use HTTPS in production: OAuth requires secure connections
- Rotate secrets regularly: Update OAuth secrets periodically
- Limit redirect URIs: Only add necessary redirect URLs
- Monitor usage: Check OAuth app analytics for suspicious activity