feishu-lark-cli-android-setup.md
2.18 KB
Feishu/Lark CLI Setup on Android/Termux
Installation
Official CLI: https://github.com/larksuite/cli
# Download latest release for linux-arm64
curl -L -o lark-cli.tar.gz "https://github.com/larksuite/cli/releases/download/v1.0.57/lark-cli-1.0.57-linux-arm64.tar.gz"
tar -xzf lark-cli.tar.gz
mv lark-cli /data/data/com.termux/files/usr/bin/lark
chmod +x /data/data/com.termux/files/usr/bin/lark
Known Issue: DNS Resolution on Android/Termux
Symptom: lark auth login fails with:
dial tcp: lookup accounts.feishu.cn on [::1]:53: read udp [::1]:xxxxx->[::1]:53: read: connection refused
Root Cause: Go's net resolver defaults to [::1]:53 on Android, which is not available.
Workaround: Use direct API calls with tenant_access_token instead of OAuth device flow.
Direct API Authentication (Workaround)
# Get tenant_access_token directly
curl -s -X POST https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal \
-H "Content-Type: application/json" \
-d '{"app_id":"YOUR_APP_ID","app_secret":"YOUR_APP_SECRET"}'
Response:
{"code":0,"expire":7200,"msg":"ok","tenant_access_token":"t-xxxxxxxx"}
Using lark-cli with Token File
When OAuth fails, create token file manually:
# Get token via curl, then create lark-cli config
mkdir -p ~/.lark-cli/hermes
echo '{"app_id":"cli_xxx","tenant_access_token":"t-xxx"}' > ~/.lark-cli/hermes/config.json
Available Commands (30+)
| Command | Function |
|---|---|
lark im |
Messages and groups |
lark docs |
Documents |
lark sheets |
Spreadsheets |
lark base |
Bases (多维表格) |
lark calendar |
Calendar |
lark drive |
File storage |
lark contact |
Contacts |
lark task |
Tasks |
lark api |
Generic API calls |
API Examples
# List chats
curl -H "Authorization: Bearer $TOKEN" https://open.feishu.cn/open-apis/im/v1/chats
# Send message
curl -X POST -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
https://open.feishu.cn/open-apis/im/v1/messages \
-d '{
"receive_id_type": "chat_id",
"receive_id": "oc_xxx",
"msg_type": "text",
"content": "{\"text\":\"Hello\"}"
}'