@ospgroupvn/lark-user-token
v1.1.0
Published
A CLI tool to get user access token from Lark/Feishu
Maintainers
Readme
Get User Access Token from Lark
Tool CLI to get user access token from Lark/Feishu.
Installation
From npm (recommended)
npm install -g lark-user-tokenTesting
The project now includes comprehensive unit tests using Jest:
# Run tests
npm test
# Run tests with coverage
npm run test:ci
# Run tests in watch mode
npm run test:watchFrom source code
git clone <repository-url>
cd src/get-user-access-token
npm install
npm run buildUsage (English)
Interactive Mode (Recommended for beginners)
# Run without any parameters for guided setup
lark-user-token
# Follow the prompts to choose your preferred command style and enter parametersCommand Line Mode
# Using short flags
lark-user-token --a YOUR_APP_ID --s YOUR_APP_SECRET --r CALLBACK_URL
# Using long flags (more descriptive)
lark-user-token --app-id YOUR_APP_ID --app-secret YOUR_APP_SECRET --redirect-uri CALLBACK_URL
# From source code
npx ts-node index.ts --a YOUR_APP_ID --s YOUR_APP_SECRET --r CALLBACK_URLParameters
--a(required): Lark App ID--s(required): Lark App Secret--r(optional): Callback URL, default ishttp://localhost:3000/callback
Notes
- Callback URL must be configured in allowed redirect URLs at Lark Developer Console
- The tool will automatically open a browser for authentication
- After successful authentication, access token and refresh token will be displayed
Examples
Interactive Mode
# Start interactive mode
lark-user-token
# The tool will guide you through:
# 1. Choose command style (short or long flags)
# 2. Enter App ID
# 3. Enter App Secret
# 4. Enter custom redirect URI (optional)
# 5. Confirm settings and proceedCommand Line Mode
# Using short flags with default callback URL
lark-user-token --a cli_a1234567890abcdef --s your_app_secret_here
# Using short flags with custom callback URL
lark-user-token --a cli_a1234567890abcdef --s your_app_secret_here --r https://your-domain.com/callback
# Using long flags (more descriptive)
lark-user-token --app-id cli_a1234567890abcdef --app-secret your_app_secret_here --redirect-uri https://your-domain.com/callbackTroubleshooting
- If the browser does not open automatically, copy the URL shown in the terminal and open it manually
- Ensure the callback URL is configured in the Lark Developer Console
- Check that App ID and App Secret are correct
Lấy User Access Token từ Lark (Tiếng Việt)
Cách sử dụng
Chế độ tương tác (Khuyến nghị cho người mới)
# Chạy không cần tham số để được hướng dẫn từng bước
lark-user-token
# Làm theo hướng dẫn để chọn kiểu lệnh và nhập các tham sốChế độ dòng lệnh
# Sử dụng flags ngắn
lark-user-token --a YOUR_APP_ID --s YOUR_APP_SECRET --r CALLBACK_URL
# Sử dụng flags dài (mô tả rõ ràng hơn)
lark-user-token --app-id YOUR_APP_ID --app-secret YOUR_APP_SECRET --redirect-uri CALLBACK_URL
# Sử dụng từ source code
npx ts-node index.ts --a YOUR_APP_ID --s YOUR_APP_SECRET --r CALLBACK_URLTham số
--a(bắt buộc): Lark App ID--s(bắt buộc): Lark App Secret--r(tùy chọn): Callback URL, mặc định làhttp://localhost:3000/callback
Lưu ý
- Callback URL cần được cấu hình trong allowed redirect urls tại Lark Developer Console
- Tool sẽ tự động mở trình duyệt để xác thực
- Sau khi xác thực thành công, access token và refresh token sẽ được hiển thị
Ví dụ
Chế độ tương tác
# Khởi động chế độ tương tác
lark-user-token
# Tool sẽ hướng dẫn bạn qua các bước:
# 1. Chọn kiểu lệnh (flags ngắn hay dài)
# 2. Nhập App ID
# 3. Nhập App Secret
# 4. Nhập custom redirect URI (tùy chọn)
# 5. Xác nhận cài đặt và tiếp tụcChế độ dòng lệnh
# Sử dụng flags ngắn với callback URL mặc định
lark-user-token --a cli_a1234567890abcdef --s your_app_secret_here
# Sử dụng flags ngắn với custom callback URL
lark-user-token --a cli_a1234567890abcdef --s your_app_secret_here --r https://your-domain.com/callback
# Sử dụng flags dài (mô tả rõ ràng hơn)
lark-user-token --app-id cli_a1234567890abcdef --app-secret your_app_secret_here --redirect-uri https://your-domain.com/callbackTroubleshooting
- Nếu trình duyệt không tự động mở, hãy copy URL được hiển thị trong terminal và mở thủ công
- Đảm bảo callback URL đã được cấu hình trong Lark Developer Console
- Kiểm tra App ID và App Secret có chính xác không
