返回 douyin-downloader
AGENTS.md
根目录 / auth / AGENTS.md
1 <!-- Parent: ../AGENTS.md -->
2 <!-- Generated: 2026-03-27 | Updated: 2026-03-27 -->
3
4 # auth
5
6 ## Purpose
7 Manages Douyin authentication credentials — cookie storage/validation and MS token generation for API request signing.
8
9 ## Key Files
10
11 | File | Description |
12 |------|-------------|
13 | `__init__.py` | Exports `CookieManager`, `MsTokenManager` |
14 | `cookie_manager.py` | Stores, validates, and serves cookies as dict or header string |
15 | `ms_token_manager.py` | Generates/refreshes the `msToken` required by Douyin API endpoints |
16
17 ## For AI Agents
18
19 ### Working In This Directory
20 - `CookieManager` is instantiated in `cli/main.py` and passed to all downloaders
21 - Cookies come from YAML config, env vars, or auto-loaded JSON files (see `config/config_loader.py`)
22 - `MsTokenManager` is used by `core/api_client.py` for request signing
23
24 ### Testing Requirements
25 - Tests: `tests/test_cookie_manager.py`, `tests/test_ms_token_manager.py`
26
27 ### Common Patterns
28 - Cookie validation checks for required Douyin cookie keys
29 - All cookie values are sanitized via `utils.cookie_utils.sanitize_cookies()`
30
31 ## Dependencies
32
33 ### Internal
34 - `utils/cookie_utils.py` — cookie parsing and sanitization helpers
35
36 ### External
37 - `aiohttp` — for token refresh HTTP calls
38
39 <!-- MANUAL: -->
40
40 lines MARKDOWN