Google Workspace Setup Skill
This skill provides a reliable method to set up Google Workspace OAuth2 authentication for the Hermes agent, addressing common issues with Python module imports and environment configuration.
Problem
The standard Google Workspace setup script (setup.py) fails with ModuleNotFoundError: No module named 'hermes_constants' when run directly because:
- The script depends on Hermes internal modules
- It needs to be run from the Hermes agent directory with proper Python path
- Virtual environment activation is required for dependencies
Solution
Always activate the Hermes virtual environment and run the setup script from the hermes-agent directory.
Prerequisites
- Google OAuth2 client secret JSON file (from Google Cloud Console)
- Hermes agent installed and accessible
Steps
Step 1: Prepare OAuth Credentials
- Go to https://console.cloud.google.com/apis/credentials
- Create/select a project
- Enable required APIs: Gmail, Calendar, Drive, Sheets, Docs, People API
- Create OAuth 2.0 Client ID (Desktop app type)
- Download the JSON file
Step 2: Copy Credentials to Hermes Directory
bash# Copy your downloaded client secret to Hermes Google Workspace skill directory cp /path/to/downloaded/client_secret_*.json ~/.hermes/skills/productivity/google-workspace/google_client_secret.json
Step 3: Run Setup with Proper Environment
bash# Change to Hermes agent directory and activate virtual environment cd ~/.hermes/hermes-agent source venv/bin/activate # Run the setup script with your client secret python ~/.hermes/skills/productivity/google-workspace/scripts/setup.py --client-secret ~/.hermes/skills/productivity/google-workspace/google_client_secret.json # You should see: "OK: Client secret saved to /Users/yourname/.hermes/google_client_secret.json"
Step 4: Get Authorization URL
bash# Still in the same terminal session (venv activated, in hermes-agent directory) python ~/.hermes/skills/productivity/google-workspace/scripts/setup.py --auth-url # Copy the entire URL output and open it in your browser
Step 5: Complete Authorization
- Open the URL from Step 4 in your browser
- Sign in with your Google account
- Grant the requested permissions
- After redirection (may show an error page - this is normal), copy the ENTIRE URL from the browser's address bar
Step 6: Exchange Authorization Code
bash# Still in the same terminal session python ~/.hermes/skills/productivity/google-workspace/scripts/setup.py --auth-code "PASTE_THE_ENTIRE_URL_FROM_STEP_5_HERE" # You should see: "OK: Token saved to /Users/yourname/.hermes/google_token.json"
Step 7: Verify Authentication
bash# Still in the same terminal session python ~/.hermes/skills/productivity/google-workspace/scripts/setup.py --check # Should output: "AUTHENTICATED"
Verification
After successful setup, you can test Google Workspace access:
bash# Test Gmail access python ~/.hermes/skills/productivity/google-workspace/scripts/google_api.py gmail search "is:unread" --max 5 # Test Calendar access python ~/.hermes/skills/productivity/google-workspace/scripts/google_api.py calendar list
Notes
- Must maintain same terminal session: Steps 3-7 need to be run in the same terminal session where the venv is activated and you're in the hermes-agent directory
- Token storage: The OAuth token is saved automatically to
~/.hermes/google_token.jsonand refreshes automatically - Re-authentication: To revoke and restart, use
--revokeflag then repeat from Step 3 - Troubleshooting:
- If you get
ModuleNotFoundErroragain, you likely left the hermes-agent directory or deactivated the venv - If you get permission errors, ensure you enabled all required APIs in Google Cloud Console
- For Advanced Protection accounts, your Workspace admin needs to allowlist the OAuth client ID
- If you get
Integration with Market Alpha Scout
Once Google Workspace is authenticated, the market_alpha_scout skill can successfully:
- Authenticate to stockbro.id via Google Workspace
- Scrape Daily Hot Stocks and Broker Summary data
- Combine with Google-based sentiment analysis for stock picks
Error Handling
Common errors and solutions:
ModuleNotFoundError: No module named 'hermes_constants'→ Not in hermes-agent directory or venv not activatedFileNotFoundErrorfor client secret → Check file path and permissionsinvalid_grant→ Token expired, redo authorization flow403: Insufficient Permission→ Missing API scopes, redo OAuth flow with all required APIs enabled


