oauth-setup
Skill này làm gì
Skill này hướng dẫn AI kết nối tài khoản dùng đăng nhập OAuth, như Gmail hoặc các dịch vụ Google khác. Skill dành cho người muốn agent dùng một tài khoản mà họ sở hữu.
Khi nào nên dùng
- ✓Khi bạn muốn agent kết nối với Gmail hoặc một dịch vụ Google khác.
- ✓Khi bạn muốn kết nối bất kỳ tài khoản nào dùng đăng nhập OAuth.
- ✓Khi kết nối OAuth thất bại vì lỗi chuyển hướng hoặc phạm vi quyền.
Liên kết skill
https://github.com/spinabot/brigade/blob/main/skills/oauth-setup/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Kết nối tài khoản Gmail của tôi để agent có thể gửi email giúp tôi, và hướng dẫn tôi cách tạo client Google.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI bắt đầu luồng đăng nhập và đưa cho bạn một liên kết để phê duyệt quyền truy cập. AI nhận mã phê duyệt qua một listener cục bộ và lưu token đăng nhập an toàn, nên bạn không phải chép mã bằng tay.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
OAuth setup
Use the oauth_authorize tool — NEVER hand-roll an http listener in bash. It opens a one-shot loopback listener on a free port (no EADDRINUSE, no port juggling), captures the code, and seals the tokens into the credential store.
The two mistakes to avoid (they cost a whole session once)
- Use a Desktop-app OAuth client, not a Web client. In Google Cloud Console → Credentials → Create OAuth client ID → Application type: Desktop app. Desktop clients accept ANY
http://127.0.0.1:<port>loopback redirect with no redirect-URI registration. A Web client requires the exact redirect URI pre-registered, which is what causesredirect_uri_mismatch. - Use the real scope. Gmail send is
https://www.googleapis.com/auth/gmail.send(NOThttps://gmail.com/..., which doesn't exist). Addopenid https://www.googleapis.com/auth/userinfo.emailif you want the account address auto-filled.
Flow
- Ask the operator to create a Desktop-app OAuth client (Gmail API enabled, consent screen in Testing with themselves as a test user) and paste the client id + secret.
- Start the flow:
oauth_authorize({ action: "start", provider: "google-gmail", authorizationEndpoint: "https://accounts.google.com/o/oauth2/v2/auth", tokenEndpoint: "https://oauth2.googleapis.com/token", userInfoEndpoint: "https://www.googleapis.com/oauth2/v3/userinfo", clientId: "<id>", clientSecret: "<secret>", scopes: ["https://www.googleapis.com/auth/gmail.send", "openid", "https://www.googleapis.com/auth/userinfo.email"], extraAuthParams: { access_type: "offline", prompt: "consent" } })access_type=offline+prompt=consentare required for a refresh token (otherwise re-auth is needed when the access token expires). - Send the operator the returned
authUrlto click. - Await the redirect — it exchanges the code and seals the tokens:
If it returns statusoauth_authorize({ action: "await", flowId: "<flowId from start>" })pending, the operator hasn't clicked yet — tell them, then callawaitagain.
Using a connected account (sending mail)
The tokens are sealed in the credential store — you can't read them from a file or the DB, and you shouldn't try. To use a connected account:
- Check what's connected:
oauth_authorize({ action: "status" })→ lists each account (provider, email, scopes, expiry). No secrets. - Get a usable token:
oauth_authorize({ action: "token", provider: "google-gmail" })→ returnsaccessToken. It auto-refreshes from the sealed refresh token when the old one expired, so you always get a live token. (Passprovideronly if more than one account is connected.) - Call the API with it. Gmail send:
POST https://gmail.googleapis.com/gmail/v1/users/me/messages/send, headerAuthorization: Bearer <accessToken>, body{ "raw": "<base64url RFC-822 message>" }.
Never cat the credential store, grep for the token, or hand-roll a refresh — action:"token" is the only retrieval path, and it keeps the refresh token + client secret sealed.
Câu hỏi thường gặp
Tôi cần loại client Google nào?
Skill yêu cầu bạn tạo client loại Desktop app trong Google Cloud, loại này hoạt động với listener đăng nhập cục bộ.
Skill dùng quyền Gmail nào?
Skill dùng quyền gửi Gmail, để agent có thể gửi thư thay bạn.
Tôi có cần dán mã không?
Không. Skill tự động nhận mã phê duyệt qua một listener cục bộ.
Chi tiết
Mô tả gốc của tác giả
Connect an OAuth 2.0 service (Gmail, Google APIs, etc.) using the built-in oauth_authorize tool — get a click-to-authorize link, auto-capture the code, and seal the tokens. Use whenever the operator asks to connect Gmail / a Google API / any OAuth account.
repo: spinabot/brigade
Độ phổ biến
- Sao GitHub
- 11k
- Vị trí xếp hạng
- #11730
- Giấy phép
- MIT
- Cập nhật
- 2/11/2026
Bình luận
- …
Thêm skill từ kho mã này
1password
11kDạy agent của bạn cài đặt công cụ dòng lệnh 1Password và đăng nhập an toàn, sau đó đọc hoặc chèn các bí mật đã lưu khi cần.
apple-reminders
11kCho phép agent của bạn xem, thêm, sửa, hoàn thành và xóa Apple Reminders từ terminal, gồm danh sách và bộ lọc theo ngày.
bluebubbles
11kCho phép agent của bạn gửi và quản lý iMessage qua BlueBubbles, gồm tin nhắn, tệp đính kèm, biểu cảm tapback, chỉnh sửa và cài đặt nhóm.
camsnap
11kCho phép agent của bạn chụp ảnh, quay clip ngắn hoặc theo dõi chuyển động từ các camera an ninh mạng mà bạn đã thiết lập.
Skill tương tự
reverse-engineer-anything
422kGiúp agent của bạn xem bên trong các app và package đã phát hành để giải thích tính năng, so sánh phiên bản hoặc hướng dẫn dựng lại bằng công cụ REA.
1password
394kGiúp agent của bạn cài đặt CLI của 1Password, đăng nhập, và đọc hoặc đưa thông tin bí mật vào mà không in giá trị ra cuộc trò chuyện.
healthcheck
394kGiúp agent của bạn rà soát bảo mật máy tính hoặc máy chủ đang chạy OpenClaw, như SSH, tường lửa, cập nhật và sao lưu, rồi đề xuất cách sửa an toàn.