360 Secure SkillHub
360 安全技能中心

Token Management

核心功能:将API令牌统一存储到指定.env文件,设置到期前7天的日历提醒,运行脚本测试令牌权限,在connections/目录记录令牌详情。典型场景:新增令牌全流程管理、调用API时查找令牌。输入支持自然语言指令,输出为操作执行反馈,可避免重复索要凭据,保障令牌安全。

nonlinear
nonlinear
热度 43.50
最近更新 2026-05-18 12:01:17
分类:开发依赖:代码执行 / 读写文件 / 第三方 API应用场景:API 集成 / 自动化脚本 / DevOps / 任务管理 ...

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add token-management
Metadata
name
token-management
description
Centralized API token management workflow. Store tokens in .env with expiration dates, test permissions via script battery, document capabilities in connections/, set calendar renewal reminders. Prevents re-asking for credentials, ensures token security, tracks expiration.
type
public
version
1.0.1
status
published
dependencies
["python3","requests","gog (for calendar reminders)"]
author
nonlinear
license
MIT

Token Management

Published: https://clawhub.com/skills/token-management

Purpose: Centralize API token management - storage, testing, documentation, expiration tracking.

Triggers:

  • "adiciona token X"
  • "salva API key pra Y"
  • "preciso de token Z"

🔴 CRITICAL RULE

ALWAYS check ~/Documents/life/.env FIRST before asking for tokens!


Workflow

When receiving a new token:

  1. Git commit (if applicable)

    • If .env is in a git repo: cd ~/Documents/life && git add -A && git commit -m "Before updating TOKEN_NAME"
    • Safety first!
  2. Ask for expiration date

    • "Quando esse token expira?"
    • Format: YYYY-MM-DD or "1 year" / "never"
  3. Store in .env

    • Location: ~/Documents/life/.env (canonical location)
    • Format: SERVICE_NAME_TOKEN=value # Expires: YYYY-MM-DD
    • Example: WILEY_JIRA_TOKEN=abc123 # Expires: 2027-02-12
  4. Create calendar reminder (if expires)

    • When: 7 days before expiration (1 week warning)
    • Event: "⚠️ Renew [SERVICE] API token (expires in 7 days)"
    • Format: All-day event
    • Command:
      gog calendar create primary \
        --summary "⚠️ Renew SERVICE token" \
        --from "YYYY-MM-DDT00:00:00-05:00" \
        --to "YYYY-MM-DDT23:59:59-05:00" \
        --description "Token expires YYYY-MM-DD. Renew at: [RENEWAL_URL]"
      
  5. Test token permissions

    • Run test battery to discover what token can do
    • Script: Use template below (adapt per service)
    • Document results in connections/ file
    • Example:
      # Test Jira token
      import requests, base64
      
      TOKEN = "..."
      EMAIL = "user@example.com"
      auth = base64.b64encode(f"{EMAIL}:{TOKEN}".encode()).decode()
      
      tests = [
          ("Get user", "GET", "/rest/api/3/myself"),
          ("List projects", "GET", "/rest/api/3/project"),
          ("Search issues", "GET", "/rest/api/3/search", {"jql": "assignee=currentUser()"}),
      ]
      
      for name, method, endpoint, *params in tests:
          r = requests.get(f"https://DOMAIN{endpoint}", 
                          headers={'Authorization': f'Basic {auth}'},
                          params=params[0] if params else None)
          print(f"{'✅' if r.ok else '❌'} {name}: {r.status_code}")
      
  6. Document in connections/

    • Create or update ~/Documents/life/connections/SERVICE.md
    • Include:
      • What token offers (read/write/scope)
      • When obtained: YYYY-MM-DD
      • Expiry date: YYYY-MM-DD
      • Renewal link: URL to get new token
      • How to use (code examples)
    • Link to .env variable name
    • Example:
      ## Token Info
      - **Obtained:** 2026-02-12
      - **Expires:** 2027-02-12
      - **Renew at:** https://id.atlassian.com/manage-profile/security/api-tokens
      - **Scope:** read-write
      - **Variable:** `WILEY_JIRA_TOKEN` (~/Documents/life/.env)
      
  7. Update token index

    • Maintain list in this SKILL.md (see below)

When needing API access:

  1. ✅ ALWAYS check .env first: ~/Documents/life/.env
  2. If not found: Check connections/ for setup instructions
  3. If still missing: Ask Nicholas for token

Token Index

Location: ~/Documents/life/.env

Example tokens:

Service Variable Scope Expires Connection Doc
Figma FIGMA_TOKEN read-write YYYY-MM-DD figma.md
Jira JIRA_TOKEN read-write YYYY-MM-DD jira.md
Slack SLACK_TOKEN bot permissions Never slack.md
GitHub GITHUB_TOKEN repo, gist YYYY-MM-DD github.md

Your index: Keep your own list in this section (local copy of skill).


Commands

Add token

# Append to .env (skill will automate)
echo "SERVICE_TOKEN=value" >> ~/Documents/life/.env

Check token exists

grep SERVICE_TOKEN ~/Documents/life/.env

List all tokens

cat ~/Documents/life/.env

.env Location

Canonical location: ~/Documents/life/.env

Why here:

  • ✅ Life infrastructure (shareable, public)
  • ✅ Survives workspace wipes
  • ✅ Consistent with connections/ folder
  • ✅ Not tied to OpenClaw workspace

Python usage:

from dotenv import load_dotenv
load_dotenv('~/Documents/life/.env')  # Or absolute path

Shell usage:

source ~/Documents/life/.env
echo $YOUR_TOKEN_NAME

Created: 2026-02-12
Updated: 2026-02-13 (sanitized for publication)