360 Secure SkillHub
360 安全技能中心

Google Workspace CLI

gws是官方Google Workspace命令行工具,支持Gmail、日历、Drive等十余种服务。核心功能含便捷快捷命令(如查看日程、邮件分类)与原生API调用,支持多种输出格式及分页。典型场景为日常办公快速处理邮件、查看日程、生成工作报告等。输入为终端命令,输出可按需调整格式;若需整合多平台日历,建议用Mac的accli。

gumadeiras
gumadeiras
热度 40.96
最近更新 2026-05-11 17:28:46
分类:协作依赖:代码执行 / 第三方 API应用场景:邮件起草 / 日程安排 / 任务管理 / 会议纪要 ...

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add gws
Metadata
name
gws
description
Google Workspace CLI (@googleworkspace/cli). Use for Gmail, Google Calendar, Drive, Sheets, Docs, Tasks, People, Chat, Meet, Forms, Keep, and more. Provides ergonomic helper commands (+agenda, +triage, +send) and raw API access. Use when you need Google Workspace access. Don't use when you need ALL calendars combined (iCloud+Google+Exchange) — use accli on Mac instead.
metadata
{"openclaw":{"requires":{"bins":["gws"]},"install":[{"id":"node","kind":"node","package":"@googleworkspace/cli","bins":["gws"],"label":"Install Google Workspace CLI (npm)"}]}}

gws — Google Workspace CLI

Official Google Workspace CLI for Gmail, Calendar, Drive, Sheets, Docs, and more.

GitHub: https://github.com/googleworkspace/cli

Quick Reference

Helper Commands (ergonomic shortcuts)

# Calendar
gws calendar +agenda                    # Upcoming events across all calendars
gws calendar +agenda --today            # Today's events
gws calendar +agenda --week --format table
gws calendar +insert                    # Create new event

# Gmail
gws gmail +triage                       # Unread inbox summary
gws gmail +triage --max 10 --format table
gws gmail +triage --query 'from:boss'
gws gmail +send                         # Send email

# Drive
gws drive +upload <file>                # Upload with auto metadata

# Workflows (cross-service)
gws workflow +standup-report            # Today's meetings + open tasks
gws workflow +meeting-prep              # Prep for next meeting
gws workflow +email-to-task             # Convert email → task
gws workflow +weekly-digest             # Weekly summary

Raw API Access

# Pattern: gws <service> <resource> <method> --params '<JSON>'

# Gmail
gws gmail users messages list --params '{"userId": "me", "maxResults": 10}'
gws gmail users messages get --params '{"userId": "me", "id": "MSG_ID"}'

# Calendar
gws calendar events list --params '{"calendarId": "primary", "maxResults": 10}'
gws calendar calendarList list

# Drive
gws drive files list --params '{"pageSize": 10}'
gws drive files get --params '{"fileId": "FILE_ID"}'

# Sheets
gws sheets spreadsheets get --params '{"spreadsheetId": "SHEET_ID"}'

# Docs
gws docs documents get --params '{"documentId": "DOC_ID"}'

Output Formats

--format json    # Default
--format table   # Human-readable
--format yaml
--format csv

Pagination

--page-all              # Auto-paginate (NDJSON output)
--page-limit <N>        # Max pages (default: 10)
--page-delay <MS>       # Delay between pages

Services

Service Description
gmail Send, read, manage email
calendar Calendars and events
drive Files, folders, shared drives
sheets Spreadsheets
docs Google Docs
slides Presentations
tasks Task lists
people Contacts
chat Chat spaces and messages
admin Users, groups, devices
forms Google Forms
keep Google Keep notes
meet Google Meet

Setup / Auth

# Check status
gws auth status

# Login (opens browser)
gws auth login

# Login with all scopes (for full access)
gws auth login --full

# Logout
gws auth logout

Credentials stored in ~/.config/gws/

Environment Variables

GOOGLE_WORKSPACE_CLI_TOKEN            # Pre-obtained access token (highest priority)
GOOGLE_WORKSPACE_CLI_CREDENTIALS_FILE # Path to OAuth credentials JSON
GOOGLE_WORKSPACE_CLI_CLIENT_ID        # OAuth client ID
GOOGLE_WORKSPACE_CLI_CLIENT_SECRET    # OAuth client secret

Examples

# Get today's agenda in table format
gws calendar +agenda --today --format table

# Check unread emails
gws gmail +triage --format table

# List recent Drive files
gws drive files list --params '{"pageSize": 5}' --format table

# Create calendar event
gws calendar +insert --title "Meeting" --start "2024-03-05T10:00:00" --end "2024-03-05T11:00:00"

# Send email
gws gmail +send --to "user@example.com" --subject "Hello" --body "Message body"

Schema Discovery

# View API schema for any method
gws schema drive.files.list
gws schema gmail.users.messages.get --resolve-refs

Troubleshooting

# Check auth status
gws auth status

# Re-authenticate
gws auth logout && gws auth login

# Dry-run (validate without sending)
gws calendar +agenda --dry-run