← 返回 Skills 市场
amiller

Google Service Accounts

作者 Andrew Miller · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
40
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install google-service-accounts
功能描述
Read or write a user's Google Sheets, Docs, Drive, or Calendar from code via a Google service account — headless, no OAuth browser flow. Use when handed a cr...
使用说明 (SKILL.md)

Google service accounts

A service account is a Google account for a script: it has an email, logs in with a key file, and reaches any Doc / Sheet / Drive file / Calendar that's been shared with its email — exactly like sharing with a coworker. No browser consent, no human clicking "Allow," no token to refresh.

1. Do you already have a key?

Look for credentials.json in the working directory, or a CREDS_JSON env var holding the JSON. The service account's address is the client_email field inside it ([email protected]). If you have it, skip to 3.

2. No key yet — walk the human through setup

Tell them plainly: this is free and needs nothing but a basic Google account. A personal gmail.com works — no credit card, no billing account. Creating the project, the service account, and the key all cost nothing, and the Sheets / Docs / Drive / Calendar APIs are free within generous daily quotas. The setup is one-time and takes a few minutes.

If they have the gcloud CLI, hand them this to run:

gcloud auth login
PROJECT="agent-bot-$(date +%s)"
gcloud projects create "$PROJECT"
gcloud config set project "$PROJECT"
gcloud services enable sheets.googleapis.com drive.googleapis.com \
  docs.googleapis.com calendar-json.googleapis.com
gcloud iam service-accounts create agent-bot --display-name="Agent Bot"
SA="agent-bot@${PROJECT}.iam.gserviceaccount.com"
gcloud iam service-accounts keys create credentials.json --iam-account="$SA"
echo "Now share your file/calendar with: $SA"

No CLI? Point them at the console walkthrough in README.md ("Click through the console") — about 20 clicks, still free. Either path ends the same: a credentials.json file and a client_email.

3. The one rule: share the file

The service account starts with access to nothing. For every file you need to touch, the human must open it → Share → paste the client_emailEditor (or Viewer for read-only) → Send. For a calendar: its settings → Share with specific people.

If you get SpreadsheetNotFound or 403 PERMISSION_DENIED, it's almost never a code bug — the file isn't shared. Tell the human exactly which file and which client_email so they fix it in one click. Don't retry blindly.

4. Use the key

Runnable examples live in quickstart.py (python quickstart.py sheets|docs|calendar). The core patterns:

Sheets (via gspread, the friendly wrapper — its default scopes include drive, so open() by name works):

import gspread
gc = gspread.service_account(filename="credentials.json")
sh = gc.open("My Spreadsheet")                 # only works because it's shared with the SA
sh.sheet1.update(values=[["hello", "from a robot"]])
sh.sheet1.append_row(["logged", "by agent"])   # the most common agent move

Any other API (Docs, Calendar, Drive, …) via google-api-python-client — one credentials object drives all of them; only the scope list changes:

from google.oauth2 import service_account
from googleapiclient.discovery import build

creds = service_account.Credentials.from_service_account_file(
    "credentials.json", scopes=["https://www.googleapis.com/auth/documents"])
docs = build("docs", "v1", credentials=creds)

In a container or CI, load the key from an env var instead of a file:

import os, json, gspread
gc = gspread.service_account_from_dict(json.loads(os.environ["CREDS_JSON"]))

5. Boundaries — don't route around these

  • Request the least scope you need; add .readonly unless you're writing. Read a document before you edit it.
  • A service account cannot read the human's private Gmail, personal Calendar, or whole Drive — only what's explicitly shared with it. That data needs the human's own OAuth browser consent; don't try to substitute the service account for it.
  • Calendar: a shared calendar's id is its owner's email (calendarId="primary" is the robot's own empty calendar), and a service account cannot add attendees to an event — Google rejects it with forbiddenForServiceAccounts. Create/edit/delete events freely; never try to send invites.
  • The service account's email is an identity, not a mailbox — mail sent to it bounces. It can't sign up for services or receive confirmation links.
  • Treat credentials.json as a password: anyone holding it is the service account. Never commit it or paste it anywhere shared.

See README.md for the full explainer — why this beats standing up your own OAuth app, the free-tier details, scope reference, and troubleshooting.

安全使用建议
Install only if you are comfortable giving an agent access to Google files or calendars you explicitly share with the service account. Use a dedicated test file first, grant Viewer/read-only access unless writes are needed, avoid running the write examples on production documents without checking the target, and keep credentials.json or CREDS_JSON private.
能力标签
requires-walletrequires-oauth-tokenrequires-sensitive-credentials
能力评估
Purpose & Capability
The stated purpose is headless access to Google Sheets, Docs, Drive, and Calendar using service accounts, and the artifacts consistently explain credential setup, file sharing, scopes, and read/write API use.
Instruction Scope
The skill clearly limits access to files or calendars shared with the service account and advises least-privilege scopes, but the quickstart Sheets and Docs examples perform writes when run against a chosen target.
Install Mechanism
Installation uses ordinary Python dependencies from requirements.txt; the packages are relevant but unpinned, so builds are not fully reproducible.
Credentials
Use of Google credentials, gcloud setup commands, and Google API libraries is proportionate to the declared purpose and is disclosed throughout the README and skill instructions.
Persistence & Privilege
The skill creates or uses a service-account JSON key, which is a persistent credential, but it repeatedly warns users to treat it as a password, avoid committing it, rotate if leaked, and prefer narrower accounts/scopes.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install google-service-accounts
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /google-service-accounts 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
Initial release: headless Google Sheets/Docs/Drive/Calendar access via a service account — share-with-the-robot setup walkthrough, runnable quickstart, scope reference, and calendar gotchas (shared-calendar id, no-attendees limit).
元数据
Slug google-service-accounts
版本 1.0.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 1
常见问题

Google Service Accounts 是什么?

Read or write a user's Google Sheets, Docs, Drive, or Calendar from code via a Google service account — headless, no OAuth browser flow. Use when handed a cr... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 40 次。

如何安装 Google Service Accounts?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install google-service-accounts」即可一键安装,无需额外配置。

Google Service Accounts 是免费的吗?

是的,Google Service Accounts 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Google Service Accounts 支持哪些平台?

Google Service Accounts 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Google Service Accounts?

由 Andrew Miller(@amiller)开发并维护,当前版本 v1.0.0。

💬 留言讨论