协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
scalekit-auth【开发与工程】Secure OAuth token management via Scalekit. Handles token storage, refresh, and retrieval for third-party services (Gmail, Slack, GitHub, etc.). Never stores tokens locally - always fetches fresh tokens from Scalekit.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Centralized OAuth token management for AI agents. No local token storage, automatic refresh, multi-service support.
Problem: OAuth tokens scattered across config files, no refresh logic, security risks.
Solution: Scalekit handles all token lifecycle:
clawhub install scalekit-auth
cd skills/scalekit-auth
pip3 install -r requirements.txt
Create skills/scalekit-auth/.env:
SCALEKIT_CLIENT_ID=your_client_id_here
SCALEKIT_CLIENT_SECRET=your_client_secret_here
SCALEKIT_ENV_URL=https://your-env.scalekit.com
Or let the agent ask you on first use.
connection_name (e.g., gmail_u3134a)Tell the agent:
"Configure Gmail for Scalekit. Connection name is gmail_u3134a"
Agent stores it in connections.json:
{
"gmail": {
"connection_name": "gmail_u3134a",
"identifier": "mess"
}
}
First API call will prompt:
Authorization needed for Gmail.
Link: https://scalekit.com/auth/... (expires in 1 minute!)
Click link → authorize → done!
#!/usr/bin/env python3
import sys
sys.path.append('./skills/scalekit-auth')
from scalekit_helper import get_token
# Get fresh token for any service
access_token = get_token("gmail")
# Use it immediately
headers = {"Authorization": f"Bearer {access_token}"}
response = requests.get("https://gmail.googleapis.com/gmail/v1/users/me/messages", headers=headers)
# Get token via CLI wrapper
TOKEN=$(python3 skills/scalekit-auth/get_token.py gmail)
# Use in API call
curl -H "Authorization: Bearer $TOKEN" \
https://gmail.googleapis.com/gmail/v1/users/me/messages
Maps service names to Scalekit connection names:
{
"gmail": {
"connection_name": "gmail_u3134a",
"identifier": "mess"
},
"slack": {
"connection_name": "slack_x7y9z",
"identifier": "mess"
}
}
Note: identifier is auto-set to agent's name (from IDENTITY.md).
Scalekit API credentials (never commit to git!):
SCALEKIT_CLIENT_ID=sk_live_...
SCALEKIT_CLIENT_SECRET=...
SCALEKIT_ENV_URL=https://...
Any OAuth provider Scalekit supports:
Check Scalekit Connectors for full list.
1. Agent calls get_token("gmail")
2. Check if connection configured → if NO, ask user
3. Check if authorized (status == ACTIVE)
4. If NOT authorized:
- Generate auth link (expires 1 min)
- Send to user via Telegram/chat
- Wait for authorization
5. Return fresh access_token
6. Scalekit auto-refreshes in background
Connection not configured:
Error: gmail not configured. Please:
1. Create connection in Scalekit dashboard
2. Provide connection_name
Authorization expired:
Authorization needed: [link]
(Link expires in 1 minute - click now!)
Scalekit credentials missing:
Scalekit not configured. Please provide:
- SCALEKIT_CLIENT_ID
- SCALEKIT_CLIENT_SECRET
- SCALEKIT_ENV_URL
[REDACTED] in logs"Module not found" error:
cd skills/scalekit-auth
pip3 install -r requirements.txt
Token returns 401:
Connection not found:
connections.json exists# In your skill's script
from scalekit_helper import get_token
import requests
def fetch_unread_emails():
token = get_token("gmail")
headers = {"Authorization": f"Bearer {token}"}
url = "https://gmail.googleapis.com/gmail/v1/users/me/messages"
params = {"q": "is:unread", "maxResults": 5}
response = requests.get(url, headers=headers, params=params)
return response.json()
If your skill uses scalekit-auth:
Document in SKILL.md:
## Prerequisites
- Install scalekit-auth skill
- Configure [SERVICE] connection in Scalekit
Import in scripts:
sys.path.append('./skills/scalekit-auth')
from scalekit_helper import get_token
Handle errors gracefully - guide users to configure connections
Returns fresh OAuth access token for the service.
Parameters:
service_name: Service identifier (e.g., "gmail", "slack")Returns:
access_token: Fresh OAuth bearer tokenRaises:
ConfigurationError: Service not configured or Scalekit creds missingAuthorizationError: User needs to authorize (sends link to user)Example:
token = get_token("gmail")
print(f"Token: {token[:10]}...") # Never log full token!
scalekit-auth config gmail gmail_u3134a)Found a bug? Have a feature request? Open an issue on ClawHub!
Remember: Tokens are secrets. Handle with care. 🔐