OAuth 2.0 Setup
This guide walks you through setting up Google OAuth 2.0 credentials to enable C4G to access your Google Sheets.
Overview
C4G uses the Google Sheets API to read configuration data from your spreadsheets. To access this API, you need to:
- Create a Google Cloud project
- Enable the Google Sheets API
- Create OAuth 2.0 credentials
- Download the credentials file
- Configure C4G to use the credentials
Step-by-Step Setup
Step 1: Create a Google Cloud Project
-
Go to Google Cloud Console
-
Sign in with your Google account
-
Click on the project dropdown at the top of the page
-
Click "New Project"
-
Enter project details:
- Project name:
C4G Game Configs(or any name you prefer) - Organization: Leave as default (optional)
- Location: Leave as default (optional)
- Project name:
-
Click "Create"
-
Wait for the project to be created (usually takes a few seconds)
Step 2: Enable Google Sheets API
-
In the Google Cloud Console, ensure your new project is selected
-
Navigate to APIs & Services → Library
- Or use the search bar and type "Google Sheets API"
-
Search for "Google Sheets API"
-
Click on "Google Sheets API"
-
Click the "Enable" button
-
Wait for the API to be enabled (a few seconds)
Step 3: Create OAuth 2.0 Credentials
-
Navigate to APIs & Services → Credentials
-
Click "+ CREATE CREDENTIALS" at the top
-
Select "OAuth client ID"
-
If prompted to configure the OAuth consent screen:
- Click "Configure Consent Screen"
- Select "External" user type
- Click "Create"
Fill in the OAuth consent screen:
- App name:
C4G Game Configs - User support email: Your email
- Developer contact email: Your email
- Click "Save and Continue"
- Skip "Scopes" (click "Save and Continue")
- Skip "Test users" (click "Save and Continue")
- Click "Back to Dashboard"
-
Return to Credentials and click "+ CREATE CREDENTIALS" again
-
Select "OAuth client ID"
-
Configure the OAuth client:
- Application type: Select "Desktop app"
- Name:
C4G Desktop Client(or any name)
-
Click "Create"
-
A dialog will appear with your client ID and client secret
Step 4: Download Credentials File
-
In the credentials dialog, click "Download JSON"
-
Save the file with a recognizable name:
- Example:
c4g_credentials.json - Example:
google_sheets_oauth.json
- Example:
-
Store this file securely - Never commit it to version control!
-
Recommended location:
YourUnityProject/
└── Credentials/
└── c4g_credentials.json -
Add to
.gitignore:# Google OAuth credentials
Credentials/
*_credentials.json
Step 5: Configure C4G with Credentials
-
Open Unity Editor
-
Open C4G Settings:
Window → C4G → Settings
-
In the Settings window, locate "Client Secret" field
-
Click the folder icon or paste the full path to your credentials JSON file:
C:/YourProject/Credentials/c4g_credentials.json -
C4G will validate the credentials file
Credentials File Format
The downloaded JSON file should look like this:
{
"installed": {
"client_id": "YOUR_CLIENT_ID.apps.googleusercontent.com",
"project_id": "your-project-id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_secret": "YOUR_CLIENT_SECRET",
"redirect_uris": ["http://localhost"]
}
}
Important: C4G specifically looks for the "installed" section for desktop applications.
First-Time Authorization Flow
When you first generate configs with C4G:
-
C4G will open your default web browser
-
Google will ask you to sign in (if not already signed in)
-
Google will show a consent screen:
- "This app isn't verified" warning may appear
- Click "Advanced"
- Click "Go to C4G Game Configs (unsafe)" (this is your own app, it's safe)
-
Review the permissions:
- C4G requests: "View your Google Spreadsheets"
- This is read-only access
-
Click "Allow"
-
You'll see a success message in the browser
-
Return to Unity - C4G will now have access to your sheets
-
The authorization token is stored locally and you won't need to re-authorize unless you revoke access
Security Best Practices
DO ✅
- Store credentials outside the Unity Assets folder for easier
.gitignoremanagement - Add credentials files to
.gitignoreimmediately - Use a dedicated Google account for game development if working in a team
- Revoke and regenerate credentials if accidentally exposed
- Keep credentials in a secure location with restricted access
- Document the credentials location for your team (but not the file itself)
DON'T ❌
- Never commit credentials to version control (Git, SVN, etc.)
- Never share credentials files via email or messaging
- Never hardcode credentials in scripts
- Don't use personal Google accounts for production/team projects
- Don't grant more permissions than "Google Sheets API" read access
Troubleshooting
"Invalid credentials" error
Cause: Credentials file is not in the correct format
Solution:
- Re-download the credentials from Google Cloud Console
- Ensure you selected "Desktop app" (not "Web application")
- Verify the JSON file has an
"installed"section
"Access denied" error
Cause: Google Sheets API is not enabled
Solution:
- Go to Google Cloud Console
- Navigate to APIs & Services → Library
- Search for "Google Sheets API"
- Click "Enable"
"Browser doesn't open for authorization"
Cause: Default browser not set or firewall blocking
Solution:
- Manually copy the authorization URL from Unity Console
- Paste it into your browser
- Complete the authorization flow
"This app isn't verified" warning
Cause: Your OAuth app hasn't gone through Google's verification process
Solution:
- This is normal for personal/development apps
- Click "Advanced" → "Go to [your app name] (unsafe)"
- For production apps, consider completing Google's app verification
"Credentials file not found"
Cause: File path is incorrect or file was moved
Solution:
- Verify the file exists at the specified path
- Use absolute paths (not relative)
- Check for typos in the file path
- Ensure Unity has read permissions for the file
Revoking Access
If you need to revoke C4G's access to your Google Sheets:
-
Find your C4G app in the list
-
Click on it and select "Remove Access"
-
You'll need to re-authorize the next time you use C4G
Team Setup
For team projects:
-
Option A: Each developer creates their own credentials
- Pros: Better security, individual access control
- Cons: Each person must set up OAuth
-
Option B: Share a team service account (Advanced)
- Use a Google Service Account instead of OAuth
- Share the service account key securely
- Not covered in this guide
Recommended: Option A for small teams, Option B for larger organizations
Next Steps
- Google Sheets Setup - Create your first config sheet
- Editor Workflow - Learn how to generate configs in Unity
- Troubleshooting - Common issues and solutions