claude-connect
Connect your Claude subscription to Clawdbot in one step.
Automatically:
- - ✅ Reads Claude OAuth tokens from Keychain
- ✅ Writes them to Clawdbot in proper OAuth format
- ✅ Auto-refreshes every 2 hours (before expiry)
- ✅ Notifies you on success/failure
- ✅ Works with
clawdbot onboard (fixes OAuth auth-profiles bug)
Quick Start
1. Install the skill:
CODEBLOCK0
2. Ensure Claude CLI is logged in:
CODEBLOCK1
3. Run installer:
CODEBLOCK2
That's it! Tokens will refresh automatically every 2 hours.
What It Does
Fixes clawdbot onboard OAuth Bug
When you run clawdbot onboard --auth-choice claude-cli, it sometimes doesn't properly write OAuth tokens to auth-profiles.json.
This skill:
- 1. Reads OAuth tokens from macOS Keychain (where Claude CLI stores them)
- Writes them to
~/.clawdbot/agents/main/agent/auth-profiles.json in proper OAuth format:
{
"profiles": {
"anthropic:claude-cli": {
"type": "oauth",
"provider": "anthropic",
"access": "sk-ant-...",
"refresh": "sk-ant-ort...",
"expires": 1234567890
}
}
}
- 3. Sets up auto-refresh (runs every 2 hours via launchd)
- Keeps your connection alive 24/7
Installation
Automatic (Recommended)
CODEBLOCK4
The installer will:
- - ✅ Verify Claude CLI is set up
- ✅ Create config file
- ✅ Set up auto-refresh job (launchd)
- ✅ Run first refresh to test
Manual
- 1. Copy example config:
CODEBLOCK5
- 2. Edit config (optional):
CODEBLOCK6
- 3. Test refresh:
CODEBLOCK7
- 4. Install launchd job (optional - for auto-refresh):
cp com.clawdbot.claude-oauth-refresher.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist
Configuration
Edit claude-oauth-refresh-config.json:
CODEBLOCK9
Options:
- -
refresh_buffer_minutes: Refresh when token has this many minutes left (default: 30) - INLINECODE7 : Where to log refresh activity
- INLINECODE8 : Notify on successful refresh (default: true)
- INLINECODE9 : Notify on failure (default: true)
- INLINECODE10 : Your Telegram chat ID (or leave empty to disable)
Usage
Manual Refresh
CODEBLOCK10
Check Status
CODEBLOCK11
Disable Notifications
Ask Clawdbot:
CODEBLOCK12
Or edit config:
{
"notifications": {
"on_success": false,
"on_failure": true
}
}
How It Works
Refresh Process
- 1. Read from Keychain: Gets OAuth tokens from INLINECODE11
- Check Expiry: Only refreshes if < 30 minutes left (or
--force) - Call OAuth API: Gets new access + refresh tokens
- Update auth-profiles.json: Writes proper OAuth format
- Update Keychain: Syncs new tokens back
- Restart Gateway: Picks up new tokens
- Notify: Sends success/failure message (optional)
Auto-Refresh (launchd)
Runs every 2 hours via INLINECODE13
Controls:
# Stop auto-refresh
launchctl unload ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist
# Start auto-refresh
launchctl load ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist
# Check if running
launchctl list | grep claude
Troubleshooting
OAuth not working after onboard
Symptom: clawdbot onboard --auth-choice claude-cli completes but Clawdbot can't use tokens
Fix:
CODEBLOCK15
This will write tokens in proper OAuth format.
Tokens keep expiring
Symptom: Auth keeps failing after 8 hours
Fix: Ensure launchd job is running:
CODEBLOCK16
No tokens in Keychain
Symptom: INLINECODE15
Fix: Log in with Claude CLI:
CODEBLOCK17
Then run refresh again:
./refresh-token.sh --force
Uninstall
CODEBLOCK19
Or manually:
# Stop auto-refresh
launchctl unload ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist
rm ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist
# Remove skill
rm -rf ~/clawd/skills/claude-connect
Upgrade
If you previously installed an older version:
CODEBLOCK21
See Also
Version: 1.1.0
Author: TunaIssaCoding
License: MIT
Repo: https://github.com/TunaIssaCoding/claude-connect
claude-connect
一键将你的 Claude 订阅连接到 Clawdbot。
自动执行:
- - ✅ 从钥匙串读取 Claude OAuth 令牌
- ✅ 以正确的 OAuth 格式将其写入 Clawdbot
- ✅ 每 2 小时自动刷新(在过期前)
- ✅ 成功/失败时通知你
- ✅ 与 clawdbot onboard 配合使用(修复 OAuth auth-profiles 错误)
快速开始
1. 安装该技能:
bash
clawdhub install claude-connect
cd ~/clawd/skills/claude-connect
2. 确保已登录 Claude CLI:
bash
claude auth
按照浏览器登录流程操作
3. 运行安装程序:
bash
./install.sh
就这样!令牌将每 2 小时自动刷新一次。
功能说明
修复 clawdbot onboard OAuth 错误
当你运行 clawdbot onboard --auth-choice claude-cli 时,它有时无法正确地将 OAuth 令牌写入 auth-profiles.json。
该技能:
- 1. 从 macOS 钥匙串(Claude CLI 存储令牌的位置)读取 OAuth 令牌
- 以正确的 OAuth 格式将其写入 ~/.clawdbot/agents/main/agent/auth-profiles.json:
json
{
profiles: {
anthropic:claude-cli: {
type: oauth,
provider: anthropic,
access: sk-ant-...,
refresh: sk-ant-ort...,
expires: 1234567890
}
}
}
- 3. 设置自动刷新(通过 launchd 每 2 小时运行一次)
- 保持你的连接全天候在线
安装
自动安装(推荐)
bash
cd ~/clawd/skills/claude-connect
./install.sh
安装程序将:
- - ✅ 验证 Claude CLI 是否已设置
- ✅ 创建配置文件
- ✅ 设置自动刷新任务(launchd)
- ✅ 运行首次刷新以进行测试
手动安装
- 1. 复制示例配置:
bash
cp claude-oauth-refresh-config.example.json claude-oauth-refresh-config.json
- 2. 编辑配置(可选):
bash
nano claude-oauth-refresh-config.json
- 3. 测试刷新:
bash
./refresh-token.sh --force
- 4. 安装 launchd 任务(可选 - 用于自动刷新):
bash
cp com.clawdbot.claude-oauth-refresher.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist
配置
编辑 claude-oauth-refresh-config.json:
json
{
refreshbufferminutes: 30,
log_file: ~/clawd/logs/claude-oauth-refresh.log,
notifications: {
on_success: true,
on_failure: true
},
notificationtarget: YOURCHAT_ID
}
选项:
- - refreshbufferminutes:当令牌剩余这么多分钟时进行刷新(默认:30)
- logfile:记录刷新活动的位置
- notifications.onsuccess:刷新成功时通知(默认:true)
- notifications.onfailure:刷新失败时通知(默认:true)
- notificationtarget:你的 Telegram 聊天 ID(留空以禁用)
使用
手动刷新
bash
立即刷新(即使未过期)
./refresh-token.sh --force
仅在需要时刷新
./refresh-token.sh
检查状态
bash
查看最近的日志
tail ~/clawd/logs/claude-oauth-refresh.log
检查认证配置文件
cat ~/.clawdbot/agents/main/agent/auth-profiles.json | jq .profiles.anthropic:claude-cli
检查 Clawdbot 状态
clawdbot models status
禁用通知
向 Clawdbot 发送指令:
禁用 Claude 刷新成功通知
或编辑配置:
json
{
notifications: {
on_success: false,
on_failure: true
}
}
工作原理
刷新流程
- 1. 从钥匙串读取: 获取 Claude Code-credentials 中的 OAuth 令牌
- 检查过期时间: 仅在剩余时间 < 30 分钟时刷新(或使用 --force)
- 调用 OAuth API: 获取新的访问令牌 + 刷新令牌
- 更新 auth-profiles.json: 写入正确的 OAuth 格式
- 更新钥匙串: 将新令牌同步回去
- 重启网关: 加载新令牌
- 通知: 发送成功/失败消息(可选)
自动刷新(launchd)
通过 ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist 每 2 小时运行一次
控制:
bash
停止自动刷新
launchctl unload ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist
启动自动刷新
launchctl load ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist
检查是否正在运行
launchctl list | grep claude
故障排除
执行 onboard 后 OAuth 无法工作
症状: clawdbot onboard --auth-choice claude-cli 完成,但 Clawdbot 无法使用令牌
解决方法:
bash
cd ~/clawd/skills/claude-connect
./refresh-token.sh --force
这将使用正确的 OAuth 格式写入令牌。
令牌持续过期
症状: 8 小时后认证持续失败
解决方法: 确保 launchd 任务正在运行:
bash
launchctl load ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist
launchctl list | grep claude
钥匙串中没有令牌
症状: 未找到 Claude Code-credentials 条目
解决方法: 使用 Claude CLI 登录:
bash
claude auth
按照浏览器流程操作
然后再次运行刷新:
bash
./refresh-token.sh --force
卸载
bash
cd ~/clawd/skills/claude-connect
./uninstall.sh
或手动卸载:
bash
停止自动刷新
launchctl unload ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist
rm ~/Library/LaunchAgents/com.clawdbot.claude-oauth-refresher.plist
移除技能
rm -rf ~/clawd/skills/claude-connect
升级
如果你之前安装了旧版本:
bash
cd ~/clawd/skills/claude-connect
./validate-update.sh # 检查更改内容
clawdhub update claude-connect # 更新到最新版本
./install.sh # 如果需要,重新运行安装程序
相关资源
版本: 1.1.0
作者: TunaIssaCoding
许可证: MIT
仓库: https://github.com/TunaIssaCoding/claude-connect