{"id":"6b993d37-ccfd-4b05-a950-459688603dfe","shortId":"r2YM9q","kind":"skill","title":"chanjing-credentials-guard","tagline":">-","description":"# Chanjing Credentials Guard\n\n## 功能说明\n\n仅通过**本地命令**引导用户配置/校验蝉镜 **AK/SK** 与 **Token**，打开登录页；**不在对话中索取密钥**。可配合其它 Chanjing 技能使用。\n\n## 运行依赖\n\n- **python3** 与 `scripts/chanjing_config.py`、`scripts/open_login_page.py`、`scripts/chanjing_get_token.py` 等\n\n## 环境变量与机器可读声明\n\n- 环境变量键名与说明：**`manifest.yaml`**（`environment` 段）及本文\n- 变量、写盘路径与权限：**`manifest.yaml`**\n\n## 使用命令\n\n- **ClawHub**（slug 以注册表为准）：`clawhub run chanjing-credentials-guard`\n- **本仓库**：`python skills/chanjing-credentials-guard/scripts/chanjing_config.py --status`\n\n---\n\n## When to Run\n\n1. **When user asks to configure/get Chanjing keys (AK/SK)**: use this skill to guide local setup.\n2. **When credentials are missing/invalid before a Chanjing API call**: use this skill to recover local config.\n\nThis skill is a **local credential guide**, not a cross-skill runtime dependency.\n\n## Execution Flow\n\n```\n1. Check if local AK/SK exists\n   └─ No  → Run open_login_page.py (open login in browser) → Ask user to run local config command\n   └─ Yes → Continue\n\n2. Check if local Token exists and is not expired\n   └─ No  → Call API to request/refresh Token → Save\n   └─ Yes → Continue\n\n3. Prompt user to continue target action\n```\n\n## Credential Storage (AK/SK read from config file)\n\nAK/SK and Token are read from the **same config file**. Path and format follow the script **`scripts/chanjing_config.py`** in this skill.\n\n- **Path**: `~/.chanjing/credentials.json`（目录由 **`CHANJING_OPENAPI_CREDENTIALS_DIR`** 覆盖，兼容 **`CHANJING_CONFIG_DIR`**）\n- **Format**:\n```json\n{\n  \"app_id\": \"Your Access Key\",\n  \"secret_key\": \"Your Secret Key\",\n  \"access_token\": \"Optional, auto-generated\",\n  \"expire_in\": 1721289220\n}\n```\n\n`expire_in` is a Unix timestamp. Token is valid for about 24 hours; refresh 5 minutes before expiry.\n\n## When AK/SK Is Missing\n\nWhen local `app_id` or `secret_key` is missing:\n\n1. **Open login page**: Run the `open_login_page.py` script to open the Chanjing sign-in page in the default browser (`https://www.chanjing.cc/openapi/login`).\n2. **Require local setup command** after the user obtains keys:\n   - Show command only; user runs it locally in terminal.\n3. **Do not request secrets in chat**:\n   - Never ask user to paste AK/SK in conversation.\n   - Never echo or store AK/SK in chat summaries.\n4. **After setting**:\n   - Ask user to run status check and then proceed to target action.\n\nCommands to set AK/SK (use either):\n\n```bash\npython scripts/chanjing_config.py --ak <your_app_id> --sk <your_secret_key>\npython skills/chanjing-credentials-guard/scripts/chanjing_config.py --ak <your_app_id> --sk <your_secret_key>\n```\n\nTo open the login page manually: `python skills/chanjing-credentials-guard/scripts/open_login_page.py`\n\n## Guide When User Wants to Generate Keys\n\nWhen the user clearly wants to **generate chanjing keys**, **get keys**, or **configure AK/SK**, follow this flow:\n\n### Step 1: Check if already configured\n\nCheck if local AK/SK already exists (read `~/.chanjing/credentials.json` for non-empty `app_id` and `secret_key`, or run `python skills/chanjing-credentials-guard/scripts/chanjing_config.py --status`).\n\n### Step 2: Branch on result\n\n- **If already configured**: ask whether user wants to overwrite local config.\n  - If yes, run guide steps.\n  - If no, stop.\n\n- **If not configured**: Run the “Guide steps” below directly.\n\n### Guide steps (when not configured or user confirmed re-apply)\n\n1. **Run `open_login_page.py`** to open the Chanjing login page in the default browser.\n2. **Explain the page flow clearly**:\n   - New users are registered automatically and the current page will display `App ID` and `Secret Key` with copy buttons.\n   - Existing users may be redirected to the console; tell them to open the left-side **API 密钥** page to view or reset keys.\n3. **Ask user to run local command to configure AK/SK**:\n   ```bash\n   python skills/chanjing-credentials-guard/scripts/chanjing_config.py --ak <your_app_id> --sk <your_secret_key>\n   ```\n4. **Secret handling rule**:\n   - Do not ask user to paste AK/SK in chat.\n   - If user shares secret in chat anyway, remind them to rotate keys and continue with local-command-only flow.\n5. **After setting**:\n   - Run status check:\n     `python skills/chanjing-credentials-guard/scripts/chanjing_config.py --status`\n   - Then proceed to target Chanjing action.\n\n## Token API (see chanjing-openapi.yaml)\n\n```http\nPOST https://open-api.chanjing.cc/open/v1/access_token\nContent-Type: application/json\n```\n\nRequest body:\n```json\n{\n  \"app_id\": \"{{app_id}}\",\n  \"secret_key\": \"{{secret_key}}\"\n}\n```\n\nResponse (success `code: 0`):\n```json\n{\n  \"code\": 0,\n  \"msg\": \"success\",\n  \"data\": {\n    \"access_token\": \"xxx\",\n    \"expire_in\": 1721289220\n  }\n}\n```\n\n- `expire_in`: Unix timestamp for token expiry\n- If `code !== 0`, AK/SK is invalid or the request failed\n\n## Validation Logic\n\n1. **AK/SK**: Read from config (path/format above, per `chanjing_config.py`); ensure `app_id` and `secret_key` are non-empty.\n2. **Token**: Ensure `access_token` exists and `expire_in > current_time + 300` (refresh 5 minutes early).\n3. **Token refresh**: Call the API above and write returned `access_token` and `expire_in` back to the file.\n\n**Shortcut**: Run `python skills/chanjing-credentials-guard/scripts/chanjing_get_token.py`; on success it prints access_token, on failure it prints guidance.\n\n## Security Boundary\n\n- This skill only handles **local credential guidance**.\n- It does not require install hooks or elevated/system-wide privileges.\n- It should not automatically execute unrelated skills.\n- It should not accept AK/SK via chat content.\n\n## Shell Config\n\n| Script | Description |\n|--------|-------------|\n| `open_login_page.py` | Opens the Chanjing login page and explains how new/existing users obtain AK/SK |\n| `chanjing_config.py` | Set or view AK/SK and Token status |\n| `chanjing_get_token.py` | Print a valid `access_token` to stdout (or guidance on failure) |\n\n```bash\n# Open login page (also runs automatically when AK/SK is missing)\npython skills/chanjing-credentials-guard/scripts/open_login_page.py\n\n# Set AK/SK manually\npython skills/chanjing-credentials-guard/scripts/chanjing_config.py --ak <app_id> --sk <secret_key>\n\n# View status\npython skills/chanjing-credentials-guard/scripts/chanjing_config.py --status\n```\n\n## With Other Skills\n\n- Other Chanjing skills may use the same local config path/format, but should keep their own runtime auth logic.\n- Guard can be used as an optional setup helper when users explicitly ask for credential guidance.\n\n## Reference\n\n- [reference.md](reference.md): API and storage format details\n- chanjing-openapi.yaml: `/access_token`, `dto.OpenAccessTokenReq`, `dto.OpenAccessTokenResp`","tags":["chanjing","credentials","guard","chan","skills","chanjing-ai","agent-skills","claude-code-skills","openclaw-skills"],"capabilities":["skill","source-chanjing-ai","skill-chanjing-credentials-guard","topic-agent-skills","topic-claude-code-skills","topic-openclaw-skills","topic-skills"],"categories":["chan-skills"],"synonyms":[],"warnings":[],"endpointUrl":"https://skills.sh/chanjing-ai/chan-skills/chanjing-credentials-guard","protocol":"skill","transport":"skills-sh","auth":{"type":"none","details":{"cli":"npx skills add chanjing-ai/chan-skills","source_repo":"https://github.com/chanjing-ai/chan-skills","install_from":"skills.sh"}},"qualityScore":"0.457","qualityRationale":"deterministic score 0.46 from registry signals: · indexed on github topic:agent-skills · 14 github stars · SKILL.md body (6,661 chars)","verified":false,"liveness":"unknown","lastLivenessCheck":null,"agentReviews":{"count":0,"score_avg":null,"cost_usd_avg":null,"success_rate":null,"latency_p50_ms":null,"narrative_summary":null,"summary_updated_at":null},"enrichmentModel":"deterministic:skill-github:v1","enrichmentVersion":1,"enrichedAt":"2026-04-22T13:03:30.887Z","embedding":null,"createdAt":"2026-04-19T00:40:57.951Z","updatedAt":"2026-04-22T13:03:30.887Z","lastSeenAt":"2026-04-22T13:03:30.887Z","tsv":"'/.chanjing/credentials.json':179,382 '/access_token':835 '/open/v1/access_token':574 '/openapi/login':264 '0':593,596,615 '1':54,103,242,370,441,625 '1721289220':210,605 '2':70,125,265,398,454,644 '24':222 '3':144,284,503,660 '300':655 '4':307,518 '5':225,551,657 'accept':722 'access':195,202,600,647,670,687,756 'action':150,321,565 'ak':331,335,516,782 'ak/sk':13,62,107,153,158,230,296,303,325,365,378,512,528,616,626,723,743,748,772,778 'alreadi':373,379,403 'also':768 'anyway':537 'api':78,137,495,567,665,829 'app':192,235,387,471,582,584,635 'appli':440 'application/json':578 'ask':57,116,292,310,405,504,524,822 'auth':808 'auto':206 'auto-gener':205 'automat':464,715,770 'back':675 'bash':328,513,764 'bodi':580 'boundari':695 'branch':399 'browser':115,261,453 'button':478 'call':79,136,663 'chanj':2,5,19,44,60,77,181,187,253,359,447,564,734,793 'chanjing-credentials-guard':1,43 'chanjing-openapi.yaml':569,834 'chanjing_config.py':633,744 'chanjing_get_token.py':752 'chat':290,305,530,536,725 'check':104,126,315,371,375,556 'clawhub':38,41 'clear':355,459 'code':592,595,614 'command':122,269,276,322,509,548 'config':86,121,156,166,188,412,629,728,800 'configur':364,374,404,423,434,511 'configure/get':59 'confirm':437 'consol':486 'content':576,726 'content-typ':575 'continu':124,143,148,544 'convers':298 'copi':477 'credenti':3,6,45,72,92,151,183,701,824 'cross':97 'cross-skil':96 'current':467,653 'data':599 'default':260,452 'depend':100 'descript':730 'detail':833 'dir':184,189 'direct':429 'display':470 'dto.openaccesstokenreq':836 'dto.openaccesstokenresp':837 'earli':659 'echo':300 'either':327 'elevated/system-wide':710 'empti':386,643 'ensur':634,646 'environ':31 'execut':101,716 'exist':108,130,380,479,649 'expir':134,208,211,603,606,651,673 'expiri':228,612 'explain':455,738 'explicit':821 'fail':622 'failur':690,763 'file':157,167,678 'flow':102,368,458,550 'follow':171,366 'format':170,190,832 'generat':207,350,358 'get':361 'guard':4,7,46,810 'guid':67,93,345,416,426,430 'guidanc':693,702,761,825 'handl':520,699 'helper':818 'hook':708 'hour':223 'http':570 'id':193,236,388,472,583,585,636 'instal':707 'invalid':618 'json':191,581,594 'keep':804 'key':61,196,198,201,239,274,351,360,362,391,475,502,542,587,589,639 'left':493 'left-sid':492 'local':68,85,91,106,120,128,234,267,281,377,411,508,547,700,799 'local-command-on':546 'logic':624,809 'login':113,244,340,448,735,766 'manifest.yaml':30,36 'manual':342,779 'may':481,795 'minut':226,658 'miss':232,241,774 'missing/invalid':74 'msg':597 'never':291,299 'new':460 'new/existing':740 'non':385,642 'non-empti':384,641 'obtain':273,742 'open':112,243,251,338,445,490,732,765 'open-api.chanjing.cc':573 'open-api.chanjing.cc/open/v1/access_token':572 'open_login_page.py':111,248,443,731 'openapi':182 'option':204,816 'overwrit':410 'page':245,257,341,449,457,468,497,736,767 'past':295,527 'path':168,178 'path/format':630,801 'per':632 'post':571 'print':686,692,753 'privileg':711 'proceed':318,561 'prompt':145 'python':48,329,333,343,394,514,557,681,775,780,786 'python3':22 're':439 're-appli':438 'read':154,162,381,627 'recov':84 'redirect':483 'refer':826 'reference.md':827,828 'refresh':224,656,662 'regist':463 'remind':538 'request':287,579,621 'request/refresh':139 'requir':266,706 'reset':501 'respons':590 'result':401 'return':669 'rotat':541 'rule':521 'run':42,53,110,119,246,279,313,393,415,424,442,507,554,680,769 'runtim':99,807 'save':141 'script':173,249,729 'scripts/chanjing_config.py':24,174,330 'scripts/chanjing_get_token.py':26 'scripts/open_login_page.py':25 'secret':197,200,238,288,390,474,519,534,586,588,638 'secur':694 'see':568 'set':309,324,553,745,777 'setup':69,268,817 'share':533 'shell':727 'shortcut':679 'show':275 'side':494 'sign':255 'sign-in':254 'sk':332,336,517,783 'skill':65,82,88,98,177,697,718,791,794 'skill-chanjing-credentials-guard' 'skills/chanjing-credentials-guard/scripts/chanjing_config.py':49,334,395,515,558,781,787 'skills/chanjing-credentials-guard/scripts/chanjing_get_token.py':682 'skills/chanjing-credentials-guard/scripts/open_login_page.py':344,776 'slug':39 'source-chanjing-ai' 'status':50,314,396,555,559,751,785,788 'stdout':759 'step':369,397,417,427,431 'stop':420 'storag':152,831 'store':302 'success':591,598,684 'summari':306 'target':149,320,563 'tell':487 'termin':283 'time':654 'timestamp':216,609 'token':15,129,140,160,203,217,566,601,611,645,648,661,671,688,750,757 'topic-agent-skills' 'topic-claude-code-skills' 'topic-openclaw-skills' 'topic-skills' 'type':577 'unix':215,608 'unrel':717 'use':63,80,326,796,813 'user':56,117,146,272,278,293,311,347,354,407,436,461,480,505,525,532,741,820 'valid':219,623,755 'via':724 'view':499,747,784 'want':348,356,408 'whether':406 'write':668 'www.chanjing.cc':263 'www.chanjing.cc/openapi/login':262 'xxx':602 'yes':123,142,414 '不在对话中索取密钥':17 '与':14,23 '仅通过':9 '以注册表为准':40 '使用命令':37 '兼容':186 '写盘路径与权限':35 '功能说明':8 '及本文':33 '变量':34 '可配合其它':18 '密钥':496 '引导用户配置':11 '打开登录页':16 '技能使用':20 '本仓库':47 '本地命令':10 '校验蝉镜':12 '段':32 '环境变量与机器可读声明':28 '环境变量键名与说明':29 '目录由':180 '等':27 '覆盖':185 '运行依赖':21","prices":[{"id":"65ed1dd9-d855-4224-a2b1-67ec4be4e44b","listingId":"6b993d37-ccfd-4b05-a950-459688603dfe","amountUsd":"0","unit":"free","nativeCurrency":null,"nativeAmount":null,"chain":null,"payTo":null,"paymentMethod":"skill-free","isPrimary":true,"details":{"org":"chanjing-ai","category":"chan-skills","install_from":"skills.sh"},"createdAt":"2026-04-19T00:40:57.951Z"}],"sources":[{"listingId":"6b993d37-ccfd-4b05-a950-459688603dfe","source":"github","sourceId":"chanjing-ai/chan-skills/chanjing-credentials-guard","sourceUrl":"https://github.com/chanjing-ai/chan-skills/tree/main/skills/chanjing-credentials-guard","isPrimary":false,"firstSeenAt":"2026-04-19T00:40:57.951Z","lastSeenAt":"2026-04-22T13:03:30.887Z"}],"details":{"listingId":"6b993d37-ccfd-4b05-a950-459688603dfe","quickStartSnippet":null,"exampleRequest":null,"exampleResponse":null,"schema":null,"openapiUrl":null,"agentsTxtUrl":null,"citations":[],"useCases":[],"bestFor":[],"notFor":[],"kindDetails":{"org":"chanjing-ai","slug":"chanjing-credentials-guard","github":{"repo":"chanjing-ai/chan-skills","stars":14,"topics":["agent-skills","claude-code-skills","openclaw-skills","skills"],"license":null,"html_url":"https://github.com/chanjing-ai/chan-skills","pushed_at":"2026-03-28T05:19:27Z","description":"蝉系openclaw 技能库，聚焦电商内容创作，提供实用的 AI 工具及技能包","skill_md_sha":"756eaa30c432f509010ebd979eb0f492e9f1046d","skill_md_path":"skills/chanjing-credentials-guard/SKILL.md","default_branch":"main","skill_tree_url":"https://github.com/chanjing-ai/chan-skills/tree/main/skills/chanjing-credentials-guard"},"layout":"multi","source":"github","category":"chan-skills","frontmatter":{"name":"chanjing-credentials-guard","description":">-"},"skills_sh_url":"https://skills.sh/chanjing-ai/chan-skills/chanjing-credentials-guard"},"updatedAt":"2026-04-22T13:03:30.887Z"}}