Search

PythonReactSEOPDF
OpenClaw

claude-oauth-renewal

Automatically detect and renew expired Claude Code OAuth tokens via heartbeat. 3-tier renewal: refresh token → Chrome browser automation → user alert.

chenhab030 source installs☆ 0 Repository stars

Installation

Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.

SkillHub CLI

skillhub install chenhab03/claude-oauth-renewal

Inspect the source and compatibility requirements, then follow its installation steps.

Give your agent the source link and ask it to inspect instructions and dependencies before explaining the installation steps.

View source ↗Guides

Skill instructions

Claude Code OAuth Auto-Renewal

Automatically detect and renew expired Claude Code OAuth tokens during OpenClaw heartbeat cycles. Prevents agent downtime caused by token expiration.

When to Use

✅ USE this skill when:

  • Your OpenClaw agent uses Claude Code as the AI provider
  • You want uninterrupted agent operation without manual token renewal
  • You're running OpenClaw on macOS with Chrome browser

How It Works

3-Tier Renewal Strategy
Heartbeat triggers check-claude-oauth.sh
  │
  ├─ Token healthy (>6h remaining) → silent exit ✓
  │
  ├─ Tier 1: claude auth status (refresh token)
  │   ├─ Success → silent exit ✓
  │   └─ Fail ↓
  │
  ├─ Tier 2: Browser automation (osascript + Chrome JXA)
  │   ├─ Start claude auth login
  │   ├─ Auto-click "Authorize" on claude.ai
  │   ├─ Extract auth code from callback page
  │   ├─ Feed code back to CLI via expect
  │   ├─ Success → silent exit ✓
  │   └─ Fail ↓
  │
  └─ Tier 3: Alert user → agent notifies via configured channel
Token Storage

Claude Code stores OAuth tokens in macOS Keychain under the service name Claude Code-credentials. The token JSON includes:

  • accessToken — API access token (prefix sk-ant-oat01-)
  • refreshToken — Used for automatic renewal (prefix sk-ant-ort01-)
  • expiresAt — Unix timestamp in milliseconds
Prerequisites
  1. macOS with security CLI (Keychain access)
  2. Claude Code installed and previously authenticated
  3. Google Chrome with View → Developer → Allow JavaScript from Apple Events enabled (for Tier 2)
  4. python3 available in PATH
  5. expect available (ships with macOS)

Setup

1. Copy the script
cp skills/claude-oauth-renewal/scripts/check-claude-oauth.sh scripts/check-claude-oauth.sh
chmod +x scripts/check-claude-oauth.sh
2. Add to HEARTBEAT.md

Add as the first step in your heartbeat execution:

## Execution Order

0. Run `bash scripts/check-claude-oauth.sh` — if output exists, r...

Source information

Source
github
Repository
openclaw/skills
Path
skills/chenhab03/claude-oauth-renewal
Version
—
Commit
3f0e900968e27934e1d2eca1db7102d4dfe75d5a
Classification source
rules
Status
active
Visibility
public

These signals come from indexed source analysis and may lag behind changes. Check the current source files.

README

Claude OAuth Renewal — OpenClaw Skill

Automatically detect and renew expired Claude Code OAuth tokens via OpenClaw heartbeat. Prevents agent downtime caused by token expiration.

How It Works

Heartbeat → check-claude-oauth.sh
  │
  ├─ Token OK (>6h) → silent exit
  │
  ├─ Tier 1: claude auth status (refresh token auto-renew)
  │   └─ Handles most cases silently
  │
  ├─ Tier 2: Chrome browser automation
  │   ├─ Start claude auth login → opens browser
  │   ├─ osascript clicks "Authorize" on claude.ai
  │   ├─ Extracts auth code from callback page
  │   └─ Feeds code back to CLI via expect
  │
  └─ Tier 3: Alert user via agent channel

Requirements

Dependency Purpose
macOS Keychain token storage
Claude Code claude CLI authenticated
python3 Token expiry parsing
Google Chrome Tier 2 browser automation
expect CLI interaction automation

Chrome setup (for Tier 2): View → Developer → Allow JavaScript from Apple Events

Install

# In your OpenClaw workspace
cp -r skills/claude-oauth-renewal/scripts/check-claude-oauth.sh scripts/
chmod +x scripts/check-claude-oauth.sh

Add to HEARTBEAT.md:

0. Run `bash scripts/check-claude-oauth.sh` — if output, relay as P0 alert

Test

# Normal check (silent if healthy)
bash scripts/check-claude-oauth.sh

# Force trigger (set threshold higher than remaining hours)
WARN_HOURS=24 bash scripts/check-claude-oauth.sh

Configuration

Env Variable Default Description
WARN_HOURS 6 Hours before expiry to start renewal

Token Details

Claude Code stores OAuth credentials in macOS Keychain:

  • Service: Claude Code-credentials
  • Key fields: accessToken, refreshToken, expiresAt (ms timestamp)
  • Read: `security find-generic-password -s "Claude Code...

Extracted content

SKILL.md
# Claude Code OAuth Auto-Renewal

Automatically detect and renew expired Claude Code OAuth tokens during OpenClaw heartbeat cycles. Prevents agent downtime caused by token expiration.

## When to Use

✅ **USE this skill when:**

- Your OpenClaw agent uses Claude Code as the AI provider
- You want uninterrupted agent operation without manual token renewal
- You're running OpenClaw on macOS with Chrome browser

## How It Works

### 3-Tier Renewal Strategy

```
Heartbeat triggers check-claude-oauth.sh
  │
  ├─ Token healthy (>6h remaining) → silent exit ✓
  │
  ├─ Tier 1: claude auth status (refresh token)
  │   ├─ Success → silent exit ✓
  │   └─ Fail ↓
  │
  ├─ Tier 2: Browser automation (osascript + Chrome JXA)
  │   ├─ Start claude auth login
  │   ├─ Auto-click "Authorize" on claude.ai
  │   ├─ Extract auth code from callback page
  │   ├─ Feed code back to CLI via expect
  │   ├─ Success → silent exit ✓
  │   └─ Fail ↓
  │
  └─ Tier 3: Alert user → agent notifies via configured channel
```

### Token Storage

Claude Code stores OAuth tokens in **macOS Keychain** under the service name `Claude Code-credentials`. The token JSON includes:

- `accessToken` — API access token (prefix `sk-ant-oat01-`)
- `refreshToken` — Used for automatic renewal (prefix `sk-ant-ort01-`)
- `expiresAt` — Unix timestamp in milliseconds

### Prerequisites

1. **macOS** with `security` CLI (Keychain access)
2. **Claude Code** installed and previously authenticated
3. **Google Chrome** with `View → Developer → Allow JavaScript from Apple Events` enabled (for Tier 2)
4. **python3** available in PATH
5. **expect** available (ships with macOS)

## Setup

### 1. Copy the script

```bash
cp skills/claude-oauth-renewal/scripts/check-claude-oauth.sh scripts/check-claude-oauth.sh
chmod +x scripts/check-claude-oauth.sh
```

### 2. Add to HEARTBEAT.md

Add as the first step in your heartbeat execution:

```markdown
## Execution Order

0. Run `bash scripts/check-claude-oauth.sh` — if output exists, r...
README
# Claude OAuth Renewal — OpenClaw Skill

Automatically detect and renew expired [Claude Code](https://docs.anthropic.com/en/docs/claude-code) OAuth tokens via [OpenClaw](https://github.com/openclaw/openclaw) heartbeat. Prevents agent downtime caused by token expiration.

## How It Works

```
Heartbeat → check-claude-oauth.sh
  │
  ├─ Token OK (>6h) → silent exit
  │
  ├─ Tier 1: claude auth status (refresh token auto-renew)
  │   └─ Handles most cases silently
  │
  ├─ Tier 2: Chrome browser automation
  │   ├─ Start claude auth login → opens browser
  │   ├─ osascript clicks "Authorize" on claude.ai
  │   ├─ Extracts auth code from callback page
  │   └─ Feeds code back to CLI via expect
  │
  └─ Tier 3: Alert user via agent channel
```

## Requirements

| Dependency | Purpose |
|-----------|---------|
| macOS | Keychain token storage |
| Claude Code | `claude` CLI authenticated |
| python3 | Token expiry parsing |
| Google Chrome | Tier 2 browser automation |
| expect | CLI interaction automation |

**Chrome setup (for Tier 2):** View → Developer → Allow JavaScript from Apple Events

## Install

```bash
# In your OpenClaw workspace
cp -r skills/claude-oauth-renewal/scripts/check-claude-oauth.sh scripts/
chmod +x scripts/check-claude-oauth.sh
```

Add to `HEARTBEAT.md`:

```markdown
0. Run `bash scripts/check-claude-oauth.sh` — if output, relay as P0 alert
```

## Test

```bash
# Normal check (silent if healthy)
bash scripts/check-claude-oauth.sh

# Force trigger (set threshold higher than remaining hours)
WARN_HOURS=24 bash scripts/check-claude-oauth.sh
```

## Configuration

| Env Variable | Default | Description |
|-------------|---------|-------------|
| `WARN_HOURS` | `6` | Hours before expiry to start renewal |

## Token Details

Claude Code stores OAuth credentials in macOS Keychain:

- **Service:** `Claude Code-credentials`
- **Key fields:** `accessToken`, `refreshToken`, `expiresAt` (ms timestamp)
- **Read:** `security find-generic-password -s "Claude Code...

Related skills

OpenClaw

openbotx

openbotx

An open-source platform for orchestrating AI agents — secure, simple, and built for everyone. Multi-agent, real-time task board, web control panel, skills system, browser automation, multi-provider, scheduler,...

OpenClaw

bambu-studio-ai

heyixuan2

Bambu Lab 3D printer control and automation. Activate when user mentions: printer status, 3D printing, slice, analyze model, generate 3D, AMS filament, print monitor, Bambu Lab, or any 3D printing task. Full pi...

OpenClaw

zsxq-digest

sealiu1997

OpenClaw skill for 知识星球 / ZSXQ digests with token-first auth and browser recovery.

OpenClaw

dojo.md

edholofy

University for AI agents. 92 courses, 4400+ scenarios, any model via OpenRouter. Auto-training loops generate per-model SKILL.md documents. Works with Claude Code, OpenClaw, Cursor, Windsurf. No fine-tuning req...