Spaces:
Sleeping
Sleeping
A newer version of the Gradio SDK is available: 6.14.0
🚀 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)
- Visit Google Cloud Console
- Create a new project or select an existing one
- Enable the Google Drive API:
- Left menu → “APIs & Services” → “Library”
- Search “Google Drive API” → click “Enable”
- 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)
- Open the Service Account you just created
- Go to the “Keys” tab
- Click “Add Key” → “Create new key”
- Choose JSON
- Click “Create” (the file downloads automatically)
- Rename it to
service-account-key.json - Place it in the project root (next to
google_drive_sync.py)
Step 3: Share the Google Drive folder (≈1 minute)
- Create a folder in Google Drive (e.g., “Chatbot_Data”)
- Right-click → “Share”
- Open
service-account-key.json, findclient_email- Example:
chatbot-drive-uploader@your-project.iam.gserviceaccount.com
- Example:
- Invite that email with “Editor” permission
- Click “Send”
Step 4: Update the code (≈1 minute)
Open google_drive_sync.py and set:
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
- Visit Google Cloud Console
- Select your project
- Left menu → “APIs & Services” → “Credentials”
- Click “Create Credentials” → “OAuth client ID”
- If prompted, configure the consent screen (choose “External”)
- App name:
Chatbot Drive Uploader - User support email: your email
- Developer contact: your email
- Click through “Save and Continue” to finish
- Click “Create Credentials” → “OAuth client ID” again
- Choose “Desktop app”
- Name it
Chatbot Desktop Client - Click “Create”
- Copy the Client ID and Client secret
Step 2: Update the code
CLIENT_ID = "your new client id"
CLIENT_SECRET = "your new client secret"
Step 3: Fetch a new refresh token
python get_refresh_token.py
📝 Notes
- The Service Account JSON is sensitive — never commit it to Git
- Add
service-account-key.jsonto.gitignore - Service Accounts are safer because no user credentials live in code