gdrive-connect-pro
FreeRuns bundled scriptsNot checkedKết nối Google Drive/Sheets trong 1 câu: agent in link uỷ quyền OAuth, người dùng bấm Allow + dán mã, agent lưu phiên làm việc và test tạo/ghi/format Sheet…
by thinhbuiii127 installs in other catalogsAbout this skill
google-sheets-connect — Kết nối Google Drive/Sheets trong 1 câu
Skill này cho agent quyền tạo và sửa file Google Sheet/Docs/Drive bằng phiên uỷ quyền của chính người dùng — quota tính vào Drive của người dùng, y như connector Google Drive của ChatGPT.
❌ Không dùng service account. Service account không có storage quota → Google chặn tạo file mới trong Drive cá nhân. Đó chính là blocker của cách cũ (phải nhờ người dùng tạo file trống trước). ✅ Dùng phiên uỷ quyền người dùng: agent đóng vai chính người dùng → tạo folder, tạo Sheet, sửa dữ liệu, format, xoá đều được.
0. KÍCH HOẠT — người dùng chỉ cần gõ
Kết nối Google Drive giúp tôi
hoặc
Cho agent quyền tạo Google Sheet
hoặc
Cài skill google-sheets-connect
Agent hiểu ngay và chạy quy trình dưới. KHÔNG hỏi người dùng về project, API, service account, terminal.
1. Quy trình agent PHẢI làm (theo đúng thứ tự)
Bước 0 — Chuẩn bị thông tin app OAuth (1 lần)
Kiểm tra máy đã có thông tin app OAuth chưa (tệp ~/.config/gdrive-connect/app.json, hoặc env GDRIVE_CLIENT_ID / GDRIVE_CLIENT_SEC):
python3 -c "import os;p=os.path.expanduser('~/.config/gdrive-connect/app.json');ok=os.path.exists(p) or (os.environ.get('GDRIVE_CLIENT_ID') and os.environ.get('GDRIVE_CLIENT_SEC'));print('OK' if ok else 'MISSING')"
OK→ sang Bước 1.MISSING→ xem mục 4 "Tạo app OAuth" rồi lưu thông tin vàoapp.json(quyền 600) hoặc env gateway.
Bước 1 — In link cấp quyền
cd <skill_dir> && python3 scripts/gdrive_connect.py start
Output là 1 URL dài. Gửi nguyên URL cho người dùng kèm hướng dẫn ngắn:
Bấm link → chọn tài khoản Google → Allow → copy mã Google hiện ra → dán lại vào chat.
Bước 2 — Nhận mã và kích hoạt phiên
Người dùng dán mã (dạng 4/0Axxxxxxxx...):
cd <skill_dir> && python3 scripts/gdrive_connect.py finish '<CODE>'
✅ Đã lưu+ email + quota → sang Bước 3.invalid_grant→ mã đã dùng/hết hạn → quay lại Bước 1.access_blocked/org_internal→ Workspace chặn app ngoài → xem mục 5.
Bước 3 — Test thật (tạo → ghi → format → đọc → xoá)
cd <skill_dir> && python3 scripts/gdrive_ops.py selftest
Kỳ vọng 6/6 ✅. Nếu có bước ⚠️ → báo đúng bước đó, không nói "thành công" chung chung.
Bước 4 — Báo kết quả (ngắn gọn)
- ✅ Đã kết nối Drive của
<email>, quota<x>GB. - Đã test tạo folder + Sheet + ghi + format + xoá → agent tạo và sửa Sheet được.
- Gợi ý: "Giờ anh gửi link Sheet bất kỳ, em sửa trực tiếp được."
- Nhắc: phiên tự gia hạn; nếu người dùng đổi mật khẩu Google hoặc thu hồi quyền thì phải kết nối lại.
2. Lệnh thao tác Sheet (dùng hằng ngày)
Tất cả qua scripts/gdrive_ops.py:
| Việc | Lệnh |
|---|---|
| Xem tài khoản đang kết nối | whoami |
| Liệt kê file | list --parent <folderId> --limit 30 |
| Tìm file | list --query "name contains 'BÁO CÁO'" |
| Tạo folder | mkdir --name "BÁO CÁO T10.2026" --parent <id> |
| Tạo Sheet mới | new-sheet --name "BÁO CÁO 1/10 - 7/10" --parent <id> |
| Xem các tab | tabs --file <id> |
| Thêm tab | add-tab --file <id> --title "Tổng quan" |
| Đọc dữ liệu | read --file <id> --range "Tổng quan!A1:H20" |
| Ghi đè vùng | write --file <id> --range "Tổng quan!A1" --values '...' |
| Thêm dòng | append --file <id> --range "Tổng quan!A1" --values '...' |
| Định dạng | format --file <id> --spec '{"repeatCell":{...}}' |
| Xoá tab | delete-tab --file <id> --sheet-id 0 --yes |
| Xoá file | delete --file <id> --yes |
| Test toàn bộ | selftest |
| Kiểm tra trạng thái | gdrive_connect.py status |
| Ngắt kết nối | gdrive_connect.py logout |
Ghi dữ liệu: mặc định USER_ENTERED (Google tự hiểu số/ngày/công thức). Muốn ghi thô đúng từng ký tự → thêm --raw.
3. Cấu trúc dữ liệu ghi vào Sheet
--valueslà JSON 2 chiều, ví dụ:'[["Chỉ số","Giá trị"],["Chi tiêu",148716339]]'- Số tiền VNĐ: ghi số trần rồi format
#,##0" đ"— KHÔNG ghi chuỗi"148.716.339 đ"(sẽ thành text, không tính toán được). - ROAS: ghi dạng text
"1.72"nếu muốn giữ đúng1.72(tránh Google tự đổi thành ngày). - Format mẫu hay dùng:
{"repeatCell":{"range":{"sheetId":0,"startRowIndex":0,"endRowIndex":1},
"cell":{"userEnteredFormat":{"textFormat":{"bold":true},
"backgroundColor":{"red":1,"green":0.95,"blue":0.6}}},
"fields":"userEnteredFormat(textFormat,backgroundColor)"}}
4. Tạo app OAuth (chỉ khi Bước 0 báo MISSING — 1 lần duy nhất)
Người dùng không cần làm phần này — agent làm, chỉ cần người dùng mở link xác nhận nếu Google yêu cầu.
- Vào
console.cloud.google.com→ tạo project (hoặc chọn project có sẵn). - APIs & Services → Library → bật Google Drive API và Google Sheets API.
- APIs & Services → OAuth consent screen → chọn External → điền tên app + email → thêm scope
drive,spreadsheets→ nếu app ở chế độ Testing thì thêm email người dùng vào Test users. - **APIs & Services → Credentials → Create credentials → OAuth client ID
Install gdrive-connect-pro in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the gdrive-connect-pro skill do?
Kết nối Google Drive/Sheets trong 1 câu: agent in link uỷ quyền OAuth, người dùng bấm Allow + dán mã, agent lưu phiên làm việc và test tạo/ghi/format Sheet thật. Dùng được cho cả Gmail cá nhân và Google Workspace, không cần gcloud, không cần vào Cloud Console.
How do I install the gdrive-connect-pro skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the gdrive-connect-pro skill run scripts?
Yes, this skill bundles executable scripts. Review the source before installing.
Related skills
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
by Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
by Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
by Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
by Anthropic