$npx -y skills add adityahimaone/hermes-agent-rtk-caveman --skill google-workspace-setupProperly set up Google Workspace OAuth2 authentication for Hermes agent, handling Python environment and module dependencies.
| 1 | # Google Workspace Setup Skill |
| 2 | |
| 3 | 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. |
| 4 | |
| 5 | ## Problem |
| 6 | The standard Google Workspace setup script (`setup.py`) fails with `ModuleNotFoundError: No module named 'hermes_constants'` when run directly because: |
| 7 | 1. The script depends on Hermes internal modules |
| 8 | 2. It needs to be run from the Hermes agent directory with proper Python path |
| 9 | 3. Virtual environment activation is required for dependencies |
| 10 | |
| 11 | ## Solution |
| 12 | Always activate the Hermes virtual environment and run the setup script from the hermes-agent directory. |
| 13 | |
| 14 | ## Prerequisites |
| 15 | - Google OAuth2 client secret JSON file (from Google Cloud Console) |
| 16 | - Hermes agent installed and accessible |
| 17 | |
| 18 | ## Steps |
| 19 | |
| 20 | ### Step 1: Prepare OAuth Credentials |
| 21 | 1. Go to https://console.cloud.google.com/apis/credentials |
| 22 | 2. Create/select a project |
| 23 | 3. Enable required APIs: Gmail, Calendar, Drive, Sheets, Docs, People API |
| 24 | 4. Create OAuth 2.0 Client ID (Desktop app type) |
| 25 | 5. Download the JSON file |
| 26 | |
| 27 | ### Step 2: Copy Credentials to Hermes Directory |
| 28 | ```bash |
| 29 | # Copy your downloaded client secret to Hermes Google Workspace skill directory |
| 30 | cp /path/to/downloaded/client_secret_*.json ~/.hermes/skills/productivity/google-workspace/google_client_secret.json |
| 31 | ``` |
| 32 | |
| 33 | ### Step 3: Run Setup with Proper Environment |
| 34 | ```bash |
| 35 | # Change to Hermes agent directory and activate virtual environment |
| 36 | cd ~/.hermes/hermes-agent |
| 37 | source venv/bin/activate |
| 38 | |
| 39 | # Run the setup script with your client secret |
| 40 | python ~/.hermes/skills/productivity/google-workspace/scripts/setup.py --client-secret ~/.hermes/skills/productivity/google-workspace/google_client_secret.json |
| 41 | |
| 42 | # You should see: "OK: Client secret saved to /Users/yourname/.hermes/google_client_secret.json" |
| 43 | ``` |
| 44 | |
| 45 | ### Step 4: Get Authorization URL |
| 46 | ```bash |
| 47 | # Still in the same terminal session (venv activated, in hermes-agent directory) |
| 48 | python ~/.hermes/skills/productivity/google-workspace/scripts/setup.py --auth-url |
| 49 | |
| 50 | # Copy the entire URL output and open it in your browser |
| 51 | ``` |
| 52 | |
| 53 | ### Step 5: Complete Authorization |
| 54 | 1. Open the URL from Step 4 in your browser |
| 55 | 2. Sign in with your Google account |
| 56 | 3. Grant the requested permissions |
| 57 | 4. After redirection (may show an error page - this is normal), copy the ENTIRE URL from the browser's address bar |
| 58 | |
| 59 | ### Step 6: Exchange Authorization Code |
| 60 | ```bash |
| 61 | # Still in the same terminal session |
| 62 | python ~/.hermes/skills/productivity/google-workspace/scripts/setup.py --auth-code "PASTE_THE_ENTIRE_URL_FROM_STEP_5_HERE" |
| 63 | |
| 64 | # You should see: "OK: Token saved to /Users/yourname/.hermes/google_token.json" |
| 65 | ``` |
| 66 | |
| 67 | ### Step 7: Verify Authentication |
| 68 | ```bash |
| 69 | # Still in the same terminal session |
| 70 | python ~/.hermes/skills/productivity/google-workspace/scripts/setup.py --check |
| 71 | |
| 72 | # Should output: "AUTHENTICATED" |
| 73 | ``` |
| 74 | |
| 75 | ## Verification |
| 76 | After successful setup, you can test Google Workspace access: |
| 77 | ```bash |
| 78 | # Test Gmail access |
| 79 | python ~/.hermes/skills/productivity/google-workspace/scripts/google_api.py gmail search "is:unread" --max 5 |
| 80 | |
| 81 | # Test Calendar access |
| 82 | python ~/.hermes/skills/productivity/google-workspace/scripts/google_api.py calendar list |
| 83 | ``` |
| 84 | |
| 85 | ## Notes |
| 86 | - **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 |
| 87 | - **Token storage**: The OAuth token is saved automatically to `~/.hermes/google_token.json` and refreshes automatically |
| 88 | - **Re-authentication**: To revoke and restart, use `--revoke` flag then repeat from Step 3 |
| 89 | - **Troubleshooting**: |
| 90 | - If you get `ModuleNotFoundError` again, you likely left the hermes-agent directory or deactivated the venv |
| 91 | - If you get permission errors, ensure you enabled all required APIs in Google Cloud Console |
| 92 | - For Advanced Protection accounts, your Workspace admin needs to allowlist the OAuth client ID |
| 93 | |
| 94 | ## Integration with Market Alpha Scout |
| 95 | Once Google Workspace is authenticated, the `market_alpha_scout` skill can successfully: |
| 96 | 1. Authenticate to stockbro.id via Google Workspace |
| 97 | 2. Scrape Daily Hot Stocks and Broker Summary data |
| 98 | 3. Combine with Google-based sentiment analysis for stock picks |
| 99 | |
| 100 | ## Error Handling |
| 101 | Common errors and solutions: |
| 102 | - `ModuleNotFoundError: No module named 'hermes_constants'` → Not in hermes-agent directory or venv not activated |
| 103 | - `FileNotFoundError` for client secret → Check file path and permissions |
| 104 | - `invalid_grant` → Token expired, redo authorization flow |
| 105 | - `403: Insufficient Permission` → Missing API scopes, redo OAuth flow with all required APIs enabled |