Token Management

统一管理API密钥,支持存储、测试、到期提醒与文档记录。

已扫描
适合谁
需要频繁使用多个API密钥的开发者、团队协作中需共享密钥且保障安全的项目管理者
不适合谁
无API密钥管理需求的普通用户、无法访问本地文件系统或未配置环境变量的用户
国内可用性
需网络配置。可能需要网络配置或第三方服务可访问。
安装难度
新手友好(★☆☆)。基于终端操作、依赖、API Key 和本地环境要求的初步判断。

安装与下载

openclaw skills install @nonlinear/token-management

Skill 说明

命令、参数、文件名以原文为准

Token Management

用途: 集中管理 API 密钥——存储、测试、文档化、过期时间追踪。

触发词:

  • "添加 token X"
  • "保存 API key 给 Y"
  • "我需要 token Z"

🔴 重要规则

**在请求 token 之前,请务必先检查 ~/Documents/life/.env!**


工作流程

当收到新的 token 时:

  1. (如适用)提交 Git

- 如果 .env 文件位于 git 仓库中:

     cd ~/Documents/life && git add -A && git commit -m "Before updating TOKEN_NAME"

- 安全第一!

  1. 询问过期日期

- "这个 token 什么时候过期?"

- 格式:YYYY-MM-DD,或 "1 year" / "never"

  1. 存入 .env 文件

- 位置: ~/Documents/life/.env(标准位置)

- 格式:SERVICE_NAME_TOKEN=value # 过期时间: YYYY-MM-DD

- 示例:WILEY_JIRA_TOKEN=abc123 # 过期时间: 2027-02-12

  1. 创建日历提醒(如果设置了过期时间)

- 时间: 提前 7 天(一周预警)

- 事件标题: "⚠️ 更新 [SERVICE] API token(7 天后过期)"

- 格式: 全天事件

- 命令:

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]"
  1. 测试 token 权限

- 运行测试脚本以确认 token 的功能范围

- 脚本: 使用下方模板(根据服务调整)

- 将测试结果记录在 connections/ 目录下

- 示例:

# 测试 Jira token
import requests, base64

TOKEN = "..."
EMAIL = "user@example.com"
auth = base64.b64encode(f"{EMAIL}:{TOKEN}".encode()).decode()

tests = [
    ("获取用户信息", "GET", "/rest/api/3/myself"),
    ("列出项目", "GET", "/rest/api/3/project"),
    ("搜索任务", "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}")
  1. 在 connections/ 中记录信息

- 创建或更新 ~/Documents/life/connections/SERVICE.md

- 包含内容:

- 该 token 提供的功能(读取/写入/权限范围)

- 获取时间: YYYY-MM-DD

- 过期时间: YYYY-MM-DD

- 续订链接: 获取新 token 的网址

- 使用方法(代码示例)

- 链接到 .env 中的变量名

- 示例:

## Token 信息
- **获取时间:** 2026-02-12
- **过期时间:** 2027-02-12
- **续订地址:** https://id.atlassian.com/manage-profile/security/api-tokens
- **权限范围:** read-write
- **环境变量:** `WILEY_JIRA_TOKEN`(位于 ~/Documents/life/.env)
  1. 更新 token 索引

- 在本 SKILL.md 文件中维护列表(见下文)

当需要 API 访问时:

  1. ✅ 始终优先检查 .env 文件: ~/Documents/life/.env
  2. 若未找到: 检查 connections/ 文件夹中的配置说明
  3. 仍缺失时: 向 Nicholas 请求 token

Token 索引

位置: ~/Documents/life/.env

服务变量名权限范围过期时间连接文档
FigmaFIGMA_TOKEN读写?[figma.md](~/Documents/life/connections/figma.md)
Jira (Wiley)WILEY_JIRA_TOKEN读写2027-02-12[jira.md](~/Documents/life/connections/jira.md)
NASNAS_HOST, NAS_USER, NAS_PASSSSH/SMB 访问-[mac.md](~/Documents/life/connections/mac.md)
Home AssistantHA_URL, HA_TOKEN读写2085-06-06TOOLS.md
TelegramTELEGRAM_CHAT_ID, TELEGRAM_PHONE消息通信--

命令

添加 token

# 追加到 .env(技能会自动处理)
echo "SERVICE_TOKEN=value" >> ~/Documents/life/.env

检查 token 是否存在

grep SERVICE_TOKEN ~/Documents/life/.env

列出所有 token

cat ~/Documents/life/.env

.env 文件位置

标准位置: ~/Documents/life/.env

为何选择此处:

  • ✅ 生活基础设施(可共享、公开)
  • ✅ 即使工作区重置也能保留
  • ✅ 与 connections/ 文件夹保持一致
  • ✅ 不绑定 OpenClaw 工作区

Python 使用方式:

from dotenv import load_dotenv
load_dotenv('/Users/nfrota/Documents/life/.env')

Shell 使用方式:

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

创建时间: 2026-02-12

位置: ~/Documents/skills/tokens/SKILL.md

N
@nonlinear

已收录 1 个 Skill

相关推荐