TurfAITurfAI User Guide
ReferenceOperations

Google OAuth Setup Guide

Synced from the TurfAI source on 2026-06-21.

Quick guide to set up Google Cloud OAuth credentials for TurfAI.


Step 1: Create Google Cloud Project (if needed)

  1. Go to Google Cloud Console
  2. Click "Select a Project" → "New Project"
  3. Name: TurfAI (or use existing project)
  4. Click "Create"

Step 2: Enable Required APIs

  1. Go to APIs & ServicesLibrary
  2. Search and enable:
    • Google+ API
    • People API

  1. Go to APIs & ServicesOAuth consent screen

  2. Choose External (for testing) or Internal (for organization only)

  3. Fill in Application Information:

    • App name: TurfAI
    • User support email: Your email
    • Developer contact: Your email
  4. Click Save and Continue

  5. Scopes (Step 2):

    • Click Add or Remove Scopes
    • Select:
      • .../auth/userinfo.email
      • .../auth/userinfo.profile
      • openid
    • Click UpdateSave and Continue
  6. Test users (Step 3) - Add your email for testing

  7. Click Save and Continue

  8. Review and click Back to Dashboard


Step 4: Create OAuth 2.0 Client ID

  1. Go to APIs & ServicesCredentials

  2. Click + CREATE CREDENTIALSOAuth 2.0 Client ID

  3. Choose Application type: Web application

  4. Name: TurfAI Web Client

  5. Authorized JavaScript origins:

    http://localhost:1337
    http://localhost:3000
  6. Authorized redirect URIs:

    http://localhost:1337/api/connect/google/callback
    http://localhost:3000/auth/callback
  7. Click Create

  8. IMPORTANT: Copy the credentials:

    • Client ID: 1234567890-abcdefg.apps.googleusercontent.com
    • Client Secret: GOCSPX-abc123def456

Step 5: Update Environment Variables

  1. Open /dms/.env
  2. Update the Google OAuth values:
GOOGLE_OAUTH_CLIENT_ID=YOUR_ACTUAL_CLIENT_ID.apps.googleusercontent.com
GOOGLE_OAUTH_CLIENT_SECRET=GOCSPX-YOUR_ACTUAL_CLIENT_SECRET
  1. Save the file

Step 6: Test OAuth Flow

  1. Start DMS:

    cd dms
    npm run develop
  2. Visit OAuth initiation URL:

    http://localhost:1337/api/connect/google
  3. You should be redirected to Google consent screen

  4. After authorizing, you'll be redirected back to TurfAI


Production Setup (Later)

For production deployment, add these redirect URIs to Google Cloud:

https://turfai-dms-eatorcypia-uc.a.run.app/api/connect/google/callback
https://turfai.io/auth/callback

And update production .env:

GOOGLE_OAUTH_REDIRECT_URI=https://turfai-dms-eatorcypia-uc.a.run.app/api/connect/google/callback
FRONTEND_URL=https://turfai.io

Troubleshooting

Error: redirect_uri_mismatch

Cause: The redirect URI doesn't match what's registered in Google Console.

Fix:

  1. Check Google Console → Credentials → Your OAuth Client
  2. Ensure exact match (including http/https, port, path)
  3. Add the exact URL from the error message

Error: invalid_client

Cause: Wrong Client ID or Client Secret.

Fix:

  1. Double-check values in .env
  2. Ensure no extra spaces or quotes
  3. Regenerate credentials if needed

Error: Access blocked

Cause: OAuth consent screen not verified or user not in test users list.

Fix:

  1. Go to OAuth consent screen
  2. Add your email to test users
  3. Retry OAuth flow

Next Steps

After Google OAuth is configured:

  1. ✅ Implement bot prevention middleware
  2. ✅ Test OAuth signup/login flow
  3. ✅ Create custom OAuth callback handler (for bot prevention)
  4. ✅ Deploy to production

Last Updated: 2025-11-08

On this page