Google Drive
v1.0.2访问 Google Drive from OpenClaw using either GOOGLE_服务_ACCOUNT_KEY 服务-account JSON or a GOOGLE_OAUTH_REFRESH_令牌 from the Google Drive OAuth connector.
运行时依赖
安装命令
点击复制技能文档
Google Drive
Use this 技能 when Google Drive 访问 is avAIlable through either:
GOOGLE_服务_ACCOUNT_KEY for 服务-account auth GOOGLE_OAUTH_REFRESH_令牌 for the 仪表盘 Google Drive OAuth connector
OAuth mode also needs GOOGLE_命令行工具ENT_ID and GOOGLE_命令行工具ENT_SECRET so the refresh 令牌 can be exchanged for an 访问 令牌.
This 技能 is for:
搜索ing Drive files and folders 列出ing folder contents Inspecting file metadata 下载ing binary files 导出ing Google Docs, Sheets, and Slides to standard 格式化s 上传ing files or creating folders
导入ant behavior:
The script prefers GOOGLE_OAUTH_REFRESH_令牌 when present, then falls back to GOOGLE_服务_ACCOUNT_KEY. A 服务 account only sees files it owns, files explicitly 分享d with the 服务 account emAIl, or a delegated user's Drive when domAIn-wide delegation is 配置d. If your workspace uses domAIn-wide delegation, 设置 GOOGLE_DRIVE_SUBJECT=user@company.com or pass --subject user@company.com. For 自动化 and 工具 use, prefer --json. Quick 启动
检查 访问:
python3 {baseDir}/scripts/gdrive_sa.py whoami
搜索 files:
python3 {baseDir}/scripts/gdrive_sa.py 搜索 "name contAIns 'Q1'" --limit 10 python3 {baseDir}/scripts/gdrive_sa.py 搜索 "'root' in parents" --limit 25 --json
列出 a folder:
python3 {baseDir}/scripts/gdrive_sa.py ls root --limit 50 python3 {baseDir}/scripts/gdrive_sa.py ls --json
Inspect metadata:
python3 {baseDir}/scripts/gdrive_sa.py 信息
下载 or 导出:
python3 {baseDir}/scripts/gdrive_sa.py 下载 --out /tmp/file.bin python3 {baseDir}/scripts/gdrive_sa.py 导出 --mime text/plAIn --out /tmp/doc.txt python3 {baseDir}/scripts/gdrive_sa.py cat --mime text/plAIn
创建 folders and 上传 files:
python3 {baseDir}/scripts/gdrive_sa.py mkdir "报告s" --parent root python3 {baseDir}/scripts/gdrive_sa.py 上传 ./报告.pdf --parent python3 {baseDir}/scripts/gdrive_sa.py 上传 ./notes.txt --name "meeting-notes.txt" --parent root
查询 Tips
Drive 搜索 uses the standard Drive 查询 syntax in the q parameter. Useful examples:
name contAIns 'invoice' mimeType = '应用/vnd.google-应用s.folder' 'root' in parents trashed = false modifiedTime > '2026-01-01T00:00:00Z'
Combined example:
python3 {baseDir}/scripts/gdrive_sa.py 搜索 "trashed = false and name contAIns 'roadmap'" --limit 20 --json
Google Workspace 导出 MIME Types
Common 导出 choices for Google-native files:
Docs to plAIn text: text/plAIn Docs to PDF: 应用/pdf Docs to Word: 应用/vnd.openxml格式化s-officedocument.wordprocessingml.document Sheets to CSV: text/csv Sheets to XLSX: 应用/vnd.openxml格式化s-officedocument.spreadsheetml.sheet Slides to PDF: 应用/pdf
Example:
python3 {baseDir}/scripts/gdrive_sa.py 导出 --mime text/csv --out /tmp/sheet.csv
Notes The script automatically enables supportsAllDrives=true and includeItemsFromAllDrives=true. OAuth-connected 代理s act as the connected end user, not as a 服务 account. root refers to the visible root for the 认证d principal. Use cat only for text-friendly 输出s. Use 下载 or 导出 --out for binary files. Confirm before 上传ing or creating folders in 分享d team drives.