# 🚀 Google Drive Quick Setup Guide If you run into `invalid_client` errors, **use the Service Account approach** (simpler and more reliable). ## ⭐ Recommended: Service Account (≈5 minutes) ### Step 1: Create a Service Account (≈2 minutes) 1. Visit [Google Cloud Console](https://console.cloud.google.com/) 2. Create a new project or select an existing one 3. Enable the Google Drive API: - Left menu → “APIs & Services” → “Library” - Search “Google Drive API” → click “Enable” 4. Create the Service Account: - Left menu → “IAM & Admin” → “Service Accounts” - Click “Create Service Account” - Name it `chatbot-drive-uploader` - Click “Create and Continue” → “Done” ### Step 2: Download the key (≈1 minute) 1. Open the Service Account you just created 2. Go to the “Keys” tab 3. Click “Add Key” → “Create new key” 4. Choose **JSON** 5. Click “Create” (the file downloads automatically) 6. Rename it to `service-account-key.json` 7. Place it in the project root (next to `google_drive_sync.py`) ### Step 3: Share the Google Drive folder (≈1 minute) 1. Create a folder in Google Drive (e.g., “Chatbot_Data”) 2. Right-click → “Share” 3. Open `service-account-key.json`, find `client_email` - Example: `chatbot-drive-uploader@your-project.iam.gserviceaccount.com` 4. Invite that email with “Editor” permission 5. Click “Send” ### Step 4: Update the code (≈1 minute) Open `google_drive_sync.py` and set: ```python SERVICE_ACCOUNT_FILE = "service-account-key.json" ``` ### Done! ✅ All data will now sync to your Drive folder automatically without manual intervention. --- ## 🔄 Alternative: Fix the OAuth client (refresh token flow) If you prefer refresh tokens, create a new OAuth client. ### Step 1: Create the OAuth client 1. Visit [Google Cloud Console](https://console.cloud.google.com/) 2. Select your project 3. Left menu → “APIs & Services” → “Credentials” 4. Click “Create Credentials” → “OAuth client ID” 5. If prompted, configure the consent screen (choose “External”) 6. App name: `Chatbot Drive Uploader` 7. User support email: your email 8. Developer contact: your email 9. Click through “Save and Continue” to finish 10. Click “Create Credentials” → “OAuth client ID” again 11. Choose **“Desktop app”** 12. Name it `Chatbot Desktop Client` 13. Click “Create” 14. Copy the **Client ID** and **Client secret** ### Step 2: Update the code ```python CLIENT_ID = "your new client id" CLIENT_SECRET = "your new client secret" ``` ### Step 3: Fetch a new refresh token ```bash python get_refresh_token.py ``` --- ## 📝 Notes - The Service Account JSON is sensitive — **never commit it to Git** - Add `service-account-key.json` to `.gitignore` - Service Accounts are safer because no user credentials live in code