{"record":{"id":"b8bc4d6b56c17643","repo":"jackwener/OpenCLI","slug":"creator-douyin-com-b8bc4d","errorCode":null,"errorMessage":"用户信息获取失败，请确认已登录 creator.douyin.com","messagePattern":"用户信息获取失败，请确认已登录 creator\\.douyin\\.com","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/douyin/profile.js","lineNumber":18,"sourceCode":"import { cli, Strategy } from '@jackwener/opencli/registry';\nimport { browserFetch } from './_shared/browser-fetch.js';\nimport { CommandExecutionError } from '@jackwener/opencli/errors';\ncli({\n    site: 'douyin',\n    name: 'profile',\n    access: 'read',\n    description: '获取账号信息',\n    domain: 'creator.douyin.com',\n    strategy: Strategy.COOKIE,\n    args: [],\n    columns: ['uid', 'nickname', 'follower_count', 'following_count', 'aweme_count'],\n    func: async (page, _kwargs) => {\n        const url = 'https://creator.douyin.com/web/api/media/user/info/?aid=1128';\n        const res = (await browserFetch(page, 'GET', url));\n        const u = res.user_info ?? res.user;\n        if (!u)\n            throw new CommandExecutionError('用户信息获取失败，请确认已登录 creator.douyin.com');\n        return [\n            {\n                uid: u.uid,\n                nickname: u.nickname,\n                follower_count: u.follower_count,\n                following_count: u.following_count,\n                aweme_count: u.aweme_count,\n            },\n        ];\n    },\n});\n","sourceCodeStart":1,"sourceCodeEnd":30,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/douyin/profile.js#L1-L30","documentation":"Thrown by the douyin profile command when the user info endpoint returns no recognizable user object (neither res.user_info nor res.user). Almost always means the browser session is not authenticated to creator.douyin.com.","triggerScenarios":"GET https://creator.douyin.com/web/api/media/user/info/ returns a payload without user_info/user — typically because cookies are missing/expired — causing `if (!u)` at clis/douyin/profile.js:18 to throw.","commonSituations":"Session cookie expired; profile was never logged in; Douyin invalidated the session (password change, risk control); running headless with a stale profile.","solutions":["Log in to creator.douyin.com in the managed browser profile and re-run.","Refresh/restore session cookies for creator.douyin.com.","Verify manually: open the same user/info URL in the browser — it should return JSON with your uid.","Check whether Douyin risk control invalidated the session (re-login required) and update the library if login flow changed."],"exampleFix":"// before: reusing a stale browser profile\nopencli douyin profile\n// after: re-authenticate first\nopencli douyin login   # or re-open the managed browser and log in\nopencli douyin profile","handlingStrategy":"validation","validationCode":"// probe login before reading profile\nconst probe = await fetch('https://creator.douyin.com/web/api/media/user/info/?aid=1128');\nconst body = await probe.json();\nif (!(body.user_info ?? body.user)) throw new Error('douyin session invalid; log in to creator.douyin.com first');","typeGuard":"function hasDouyinUser(res) {\n  return res != null && typeof res === 'object' && Boolean(res.user_info ?? res.user);\n}","tryCatchPattern":"try {\n  const profile = await douyinProfile();\n} catch (e) {\n  if (String(e.message).includes('请确认已登录')) {\n    await openDouyinLogin();\n    return douyinProfile();\n  }\n  throw e;\n}","preventionTips":["Re-login to creator.douyin.com whenever sessions age out (cookies typically expire in days).","Probe the user/info endpoint as a health check in scheduled jobs.","Keep the browser profile persistent so cookies survive restarts.","Watch for douyin risk-control logouts after long idle periods."],"tags":["douyin","auth","session-expired"],"backgroundTag":"session-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}