Language
Match user's language: Respond in the same language the user uses.
Overview
Switch between multiple lark-cli Feishu account configurations. Each profile corresponds to a Feishu app (App ID + Secret), by replacing ~/.lark-cli/config.json to achieve the switch. The token is saved with the config file, so no re-authorization is needed after switching.
Runtime
Preflight
bash <SKILL_DIR>/scripts/helper.sh preflight
Check whether lark-cli is installed, whether the config directory exists, and which profiles are available.
Switch account
source ~/.lark-cli/switch.sh <profile>
Example:
source ~/.lark-cli/switch.sh personal # 切到个人账号
source ~/.lark-cli/switch.sh einsia # 切到 Einsia 组织账号
source ~/.lark-cli/switch.sh # 查看所有可用 profiles
Verify the switch result
lark-cli auth status
Should return tokenStatus: "valid" and the correct userName。
Add Profile
When the user needs to add a new Feishu account:
# 1. 配置应用
echo "<app-secret>" | lark-cli config init --app-id <app-id> --app-secret-stdin --brand feishu
# 2. 登录用户身份
lark-cli auth login --domain docs,wiki,drive
# 3. 保存 profile
cp ~/.lark-cli/config.json ~/.lark-cli/config-<name>.json
# 4. 保存 secret(用于 keychain 恢复)
echo -n "<app-secret>" > ~/.lark-cli/.<name>.secret
chmod 600 ~/.lark-cli/.<name>.secret
# 5. 恢复之前的活跃 profile
source ~/.lark-cli/switch.sh <previous-profile>
Note:lark-cli config init is a destructive operation and will overwrite the current config.json. Before adding a profile, be sure to confirm that the current profile has been saved.
Token expiration handling
The token is valid for about 2 hours, and the refresh token for 7 days. If after switching auth status shows the token has expired:
lark-cli auth login --domain docs,wiki,drive
# 登录后重新保存 profile
cp ~/.lark-cli/config.json ~/.lark-cli/config-<current-profile>.json
Troubleshooting
| Symptom | Cause | Solution |
|---|---|---|
keychain entry not found |
The secret for that appId in the keychain has been cleared | From .<profile>.secret file, or re- config init |
client secret is invalid |
The secret in the Feishu backend has been refreshed | Obtain the new secret, re- config init and save |
app is pending approval |
The organization app has not been approved | Contact the administrator for approval |
| Re-authorization is required after switching | The token in the config file is lost | Confirm that the complete config after login was saved |