This guide will help you set up Google OAuth authentication for Bitinfrashop.
- Go to Google Cloud Console
- Click "Select a project" → "New Project"
- Enter project name:
Bitinfrashop(or your preferred name) - Click "Create"
- In the Google Cloud Console, go to "APIs & Services" → "Library"
- Search for "Google+ API" or "Google Identity"
- Click on "Google+ API" and click "Enable"
- Go to "APIs & Services" → "Credentials"
- Click "Create Credentials" → "OAuth 2.0 Client IDs"
- If prompted, configure the OAuth consent screen:
- Choose "External" user type
- Fill in required fields:
- App name:
Bitinfrashop - User support email: Your email
- Developer contact: Your email
- App name:
- Add scopes:
email,profile,openid - Add test users (your email address)
- Application type: "Web application"
- Name:
Bitinfrashop Web Client - Authorized redirect URIs:
- For development:
http://localhost:3000/api/auth/callback/google - For production:
https://yourdomain.com/api/auth/callback/google
- For development:
- Click "Create"
- Copy the Client ID and Client Secret
- Keep these secure - you'll need them for environment variables
Add the following to your .env.local file:
# NextAuth.js Configuration
NEXTAUTH_SECRET=your_nextauth_secret_here
NEXTAUTH_URL=http://localhost:3000
# Google OAuth Configuration
GOOGLE_CLIENT_ID=your_google_client_id_here
GOOGLE_CLIENT_SECRET=your_google_client_secret_hereGenerate a secure secret for NextAuth:
# Option 1: Using Node.js
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
# Option 2: Using OpenSSL
openssl rand -hex 32
# Option 3: Online generator
# Visit: https://generate-secret.vercel.app/32npm run dev- Go to
http://localhost:3000/login - Click "Continue with Google"
- Complete the Google OAuth flow
- You should be redirected back to the dashboard
- Go back to Google Cloud Console → "Credentials"
- Edit your OAuth 2.0 Client ID
- Add production redirect URI:
https://yourdomain.com/api/auth/callback/google - Update authorized domains if needed
Update your production environment variables:
NEXTAUTH_URL=https://yourdomain.com
GOOGLE_CLIENT_ID=your_production_client_id
GOOGLE_CLIENT_SECRET=your_production_client_secret
NEXTAUTH_SECRET=your_production_secret- Cause: Redirect URI doesn't match what's configured in Google Console
- Solution: Ensure redirect URI in Google Console exactly matches your domain
- Cause: OAuth consent screen not properly configured
- Solution: Complete the OAuth consent screen setup in Google Console
- Cause: Wrong Client ID or Client Secret
- Solution: Double-check environment variables match Google Console
- Cause: Database schema not updated
- Solution: Run
npx prisma db pushto apply schema changes
Enable debug mode in development:
NEXTAUTH_DEBUG=true- Never commit
.env.localor.envfiles to version control - Use different credentials for development and production
- Rotate secrets regularly in production
- Monitor OAuth usage in Google Cloud Console
- Use HTTPS in production (required by Google OAuth)
Need help? Contact: nodediver@proton.me