google-workspace
Access Google Workspace APIs (Drive, Docs, Calendar, Gmail, Sheets, Slides, Chat, People) via local helper scripts without MCP. Handles OAuth login and direct API calls.
How do I install this agent skill?
npx skills add https://github.com/mitsuhiko/agent-stuff --skill google-workspaceIs this agent skill safe to install?
- Gen Agent Trust Hubwarn
This skill facilitates Google Workspace API access but exhibits several security risks. Most notably, it transmits OAuth refresh tokens to a third-party service (geminicli.com) in its default 'cloud' mode. Additionally, it executes arbitrary JavaScript through the Node.js 'vm' module and automatically installs dependencies via 'npm install'. It also lacks sanitization for data retrieved from Workspace APIs, creating an attack surface for indirect prompt injection.
- Socketwarn
1 alert: gptAnomaly
- Snykwarn
Risk: MEDIUM · 2 issues
- Runlayerwarn
6/6 files flagged
- ZeroLeakspass
Score: 93/100 · 2 sections analyzed
What does this agent skill do?
Google Workspace
Use this skill for Google Workspace tasks (Gmail, Drive, Calendar, Docs, Sheets, etc.).
Files
scripts/auth.js— OAuth login/status/clear + account enumerationscripts/workspace.js— JavaScript execution based API runner
Account model (multi-account)
This skill is profile-based by email address.
- There is no default account.
- Every API call must specify
--email <account@example.com>. - Tokens are stored per-email under
~/.pi/google-workspace/tokens/.
Before running API calls, discover available signed-in accounts:
node scripts/auth.js accounts
Usage
Always use exec and always provide --email.
node scripts/workspace.js exec --email user@example.com <<'JS'
const me = await workspace.whoAmI();
const files = await workspace.call('drive', 'files.list', {
pageSize: 5,
fields: 'files(id,name,mimeType)',
});
return { me, files: files.files };
JS
Available inside exec scripts:
auth(authorized OAuth client)google(googleapisroot)workspace.accountEmail(selected profile email)workspace.call(service, methodPath, params, {version})workspace.service(service, {version})workspace.whoAmI()
Optional flags:
--timeout <ms>(default 30000, max 300000)--scopes s1,s2--script 'return 42'
Agent guidance
- Prefer one
execscript per user request. - Keep payloads small (
fields,maxResults, minimal props). - Use
Promise.allfor independent requests. - Never print token contents.
- If the user did not specify an account, run
node scripts/auth.js accountsand choose/confirm an explicit email. - If auth fails, first run
node scripts/auth.js accountsto see known profiles. - If account mismatch is possible, run
workspace.whoAmI()in the selected profile. - On 401/403/unauthorized errors, switch account (
--email ...) or re-login that specific profile.
Unauthorized/account-switch playbook
If a request fails with unauthorized/forbidden/insufficient permissions:
- Enumerate profiles:
node scripts/auth.js accounts
- Retry with the intended account:
node scripts/workspace.js exec --email correct-user@example.com <<'JS'
return await workspace.whoAmI();
JS
- If token is stale or missing scopes, re-login that account:
node scripts/auth.js login --email correct-user@example.com
- Retry the original request with the same
--email.
Short Gmail counting example
node scripts/workspace.js exec --email user@example.com <<'JS'
const gmail = google.gmail({ version: 'v1', auth });
let trash = 0;
let pageToken;
do {
const res = await gmail.users.messages.list({
userId: 'me',
q: 'in:trash',
maxResults: 500,
pageToken,
fields: 'messages/id,nextPageToken',
});
trash += (res.data.messages || []).length;
pageToken = res.data.nextPageToken;
} while (pageToken);
return { currentlyInTrash: trash };
JS
Setup + auth
node scripts/auth.js login --email user@example.com
Notes:
- Dependencies auto-install on first run.
- Default auth mode is cloud (no local
credentials.jsonneeded). - Optional local mode:
GOOGLE_WORKSPACE_AUTH_MODE=localand credentials at~/.pi/google-workspace/credentials.json. - Useful diagnostics:
node scripts/auth.js accounts
node scripts/auth.js status --email user@example.com
node scripts/auth.js clear --email user@example.com
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/mitsuhiko/agent-stuff/google-workspace">View google-workspace on skillZs</a>