Skip to content

feat: support User Access Token for doc export#33

Merged
riba2534 merged 2 commits intoriba2534:mainfrom
mojitote:feat/doc-export-user-token
Mar 15, 2026
Merged

feat: support User Access Token for doc export#33
riba2534 merged 2 commits intoriba2534:mainfrom
mojitote:feat/doc-export-user-token

Conversation

@mojitote
Copy link

允许读取 App Token 无法访问的文档(例如:未给 App 协作权限、但由其他人拥有的文档)。

具体改动如下:
• internal/client/docx.go
新增 ListBlocksWithToken 和 GetAllBlocksWithToken 方法,这两个方法支持传入 可选的 User Access Token。
现有函数保留不变,并作为 不带 token 的包装函数(wrapper) 以保证向后兼容。
• cmd/export_markdown.go
新增 --user-access-token 参数。
如果没有显式提供该参数,程序会自动从 auth login 生成的 token.json 中解析并使用 token。
• skills/feishu-cli-read/SKILL.md
文档中新增说明:
• User Token 作为 fallback 的行为
• 新增的 --user-access-token 参数
• 错误码 1770032 和 99991679 的说明
• README.md
在权限表中新增 User Scope:
• docx:document:readonly
• search:docs:read
• offline_access
同时新增 quick-import JSON 示例中的 user 权限数组。

xinghaoyuan and others added 2 commits March 15, 2026 13:57
Allow reading documents that the App token cannot access (e.g. documents
owned by others without App collaboration permission).

- internal/client/docx.go: add ListBlocksWithToken and GetAllBlocksWithToken
  accepting an optional User Access Token; existing functions remain as
  zero-token wrappers for backward compatibility
- cmd/export_markdown.go: add --user-access-token flag; automatically
  resolves token from auth login token.json when flag is not provided
- skills/feishu-cli-read/SKILL.md: document User Token fallback behavior,
  new --user-access-token flag, and error codes 1770032 / 99991679
- README.md: add User scope rows (docx:document:readonly, search:docs:read,
  offline_access) to permissions table and quick-import JSON user array
…ccuracy

- Add resolveOptionalUserTokenWithFallback helper to cmd/utils.go for
  consistent token resolution pattern (full priority chain, no error on empty)
- Simplify export_markdown.go to use the new helper, remove direct auth import
- Fix SKILL.md token priority description to match actual code behavior
  (User Token first when available, App Token as fallback)
- Add --user-access-token param and error codes (1770032/99991679) to
  feishu-cli-export/SKILL.md
- Add doc export --user-access-token example to README.md

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@riba2534 riba2534 merged commit e9b263a into riba2534:main Mar 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants