← 返回教學
連接 Google Workspace
先決條件(兩種方法通用)
1
建立 Google Cloud OAuth 憑證
此步驟在您自己的瀏覽器中完成 — MyClaw 實例上不需要做任何事。
- 開啟 Google Cloud Console → APIs & Services → Credentials。
- 點擊 + CREATE CREDENTIALS → OAuth client ID → Application type: Desktop app。
- 點擊 Create → 下載 JSON。儲存 client_secret_xxx.json 檔案 — 稍後會用到。
您還必須配置 OAuth consent screen 並在 APIs & Services → OAuth consent screen 下將自己新增為 Test user。否則授權將失敗。
2
啟用 Gmail API 和 Google Calendar API
點擊下方每個連結並點擊 Enable。每個只需幾秒鐘。
只需要日曆?只需啟用 Calendar API(後續步驟使用 --services calendar)。
無需命令。從聊天視窗完成一切(Telegram / WebChat)。
B.1
要求 OpenClaw 安裝 gog
OpenClaw
您
Install gog for me
OpenClaw
Installing...
✅ gog v0.11.0 installed!
B.2
發送憑證檔案
OpenClaw
您
client_secret_xxx.json
Connect my Gmail and CalendarOpenClaw
Got the credentials file, configuring...
✅ Credentials imported. What's your Gmail address?
B.3
提供電子郵件,取得授權連結
OpenClaw
您
your@gmail.com
OpenClaw
Please open this link in your browser to authorize:
https://accounts.google.com/o/oauth2/auth?...
After authorizing, the page will redirect to 127.0.0.1 and show an error — that's normal. Copy the full URL from your address bar and send it to me.
B.4
貼上回呼 URL
OpenClaw
您
http://127.0.0.1:42845/oauth2/callback?state=xxx&code=xxx...
OpenClaw
✅ Gmail + Calendar connected!
You can now just say:
• "Check my recent emails"
• "Create a meeting for tomorrow at 3 PM"
就是這樣 — 三則訊息即可完成連接。
現在您可以做什麼
| 功能 | 只需說 |
|---|---|
| 📧 查看電子郵件 | 「查看我最近的電子郵件」/ 「有 xxx 寄來的郵件嗎?」 |
| 📧 發送電子郵件 | 「發一封郵件給 a@b.com 關於...」 |
| 📅 查看行事曆 | 「這週我的行程是什麼?」 |
| 📅 建立事件 | 「安排週五下午 2 點的會議」 |
| 📧 草擬電子郵件 | 「草擬那封郵件的回覆」 |
疑難排解
Q: 授權時出現「Access blocked」或「App not verified」
A: 您沒有在 OAuth consent screen 上將自己新增為 Test user。返回步驟 1,開啟 OAuth consent screen → Test users,並新增您的 Gmail 地址。
Q: 403 accessNotConfigured 錯誤
A: API 未啟用。返回步驟 2,確認 Gmail API 和 Calendar API 都顯示「Enabled」。
Q: 回呼 URL 過期
A: 重新執行授權步驟即可 — 很快。告訴 OpenClaw「重新授權」,它會給您一個新連結。
Q: WebSSH 中出現 no TTY available for keyring 錯誤
A: 在命令前加上 GOG_KEYRING_PASSWORD="anypassword",例如:
GOG_KEYRING_PASSWORD="mypass123" gog auth add your@gmail.com ...