This skill is a local credential guide, not a runtime dependency for other skills. It does not require bundled helper scripts to be present.
text
1. Check if local AK/SK exists
└─ No → Open login page URL in browser → Ask user to configure local file
└─ Yes → Continue
2. Check if local Token exists and is not expired
└─ No → Call API to request/refresh Token → Save to local file
└─ Yes → Continue
3. Prompt user to continue target action
AK/SK and Token are read from the same local config file.
~/.chanjing/credentials.json (overridable by env CHANJING_CONFIG_DIR)json
{
"app_id": "Your Access Key",
"secret_key": "Your Secret Key",
"access_token": "Optional, auto-generated",
"expire_in": 1721289220
}
expire_in is a Unix timestamp. Token is valid for about 24 hours; refresh 5 minutes before expiry.
When local app_id or secret_key is missing:
Open login page: open https://www.chanjing.cc/openapi/login in the default browser.
Require local setup after the user obtains keys:
credentials.json file.Do not request secrets in chat:
After setting:
Manual update example:
json
{
"app_id": "<your_app_id>",
"secret_key": "<your_secret_key>"
}
When the user clearly wants to generate chanjing keys, get keys, or configure AK/SK, follow this flow:
Check if local AK/SK already exists (read ~/.chanjing/credentials.json for non-empty app_id and secret_key).
Open https://www.chanjing.cc/openapi/login in browser.
Explain the page flow clearly:
App ID and Secret Key with copy buttons.Ask user to configure local file ~/.chanjing/credentials.json (or $CHANJING_CONFIG_DIR/credentials.json) with app_id and secret_key.
Secret handling rule:
After setting:
app_id and secret_key.http
POST https://open-api.chanjing.cc/open/v1/access_token
Content-Type: application/json
Request body:
json
{
"app_id": "{{app_id}}",
"secret_key": "{{secret_key}}"
}
Response (success code: 0):
json
{
"code": 0,
"msg": "success",
"data": {
"access_token": "xxx",
"expire_in": 1721289220
}
}
expire_in: Unix timestamp for token expirycode !== 0, AK/SK is invalid or the request failedapp_id and secret_key are non-empty.access_token exists and expire_in > current_time + 300 (refresh 5 minutes early).access_token and expire_in back to the file./access_token, dto.OpenAccessTokenReq, dto.OpenAccessTokenResp