{"record":{"id":"6fa053ad60814d6e","repo":"jackwener/OpenCLI","slug":"xiaohongshu-creator-profile-requires-login-deta","errorCode":null,"errorMessage":"Xiaohongshu creator profile requires login: ${detail}","messagePattern":"Xiaohongshu creator profile requires login: (.+?)","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/xiaohongshu/auth.js","lineNumber":28,"sourceCode":"async function verifyXhsIdentity(page) {\n  await page.goto('https://creator.xiaohongshu.com/new/home');\n  const payload = await page.evaluate(`\n    async () => {\n      try {\n        const resp = await fetch('/api/galaxy/creator/home/personal_info', { credentials: 'include' });\n        const text = await resp.text();\n        let parsed = null;\n        try { parsed = JSON.parse(text); } catch {}\n        return [resp.ok, resp.status, parsed, text.slice(0, 200)];\n      } catch (error) {\n        return [false, 0, null, String(error && error.message || error)];\n      }\n    }\n  `);\n  const [ok, status, parsed, preview] = Array.isArray(payload) ? payload : [];\n  if (!ok) {\n    const detail = parsed?.msg ?? preview ?? `HTTP ${status ?? ''}`;\n    throw new AuthRequiredError('creator.xiaohongshu.com', `Xiaohongshu creator profile requires login: ${detail}`);\n  }\n  const data = parsed?.data;\n  if (!data) {\n    throw new CommandExecutionError('Xiaohongshu creator profile returned malformed personal_info payload');\n  }\n  return {\n    username: data.name ?? '',\n    followers: data.fans_count ?? 0,\n  };\n}\n\nregisterSiteAuthCommands({\n  site: 'xiaohongshu',\n  domain: 'creator.xiaohongshu.com',\n  loginUrl: 'https://creator.xiaohongshu.com/',\n  columns: ['username', 'followers'],\n  quickCheck: hasXhsSessionCookies,\n  verify: verifyXhsIdentity,","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/xiaohongshu/auth.js#L10-L46","documentation":"verifyXhsIdentity evaluates a fetch of the creator.xiaohongshu.com personal_info API in the page; if the request does not succeed (ok falsy), it throws AuthRequiredError for creator.xiaohongshu.com including the API's msg, a response preview, or the HTTP status. It means XHS does not consider the browser session logged in as a creator.","triggerScenarios":"payload[0] (ok) is false because the personal_info endpoint returned a non-success response — e.g. an auth redirect, an error body with msg like '未登录', or a non-2xx status.","commonSituations":"Creator-session cookies expired; user logged into www.xiaohongshu.com but not creator.xiaohongshu.com; XHS invalidated the session (password change, security check); hitting the endpoint from a flagged IP/datacenter.","solutions":["Run the login flow for creator.xiaohongshu.com and complete any security verification.","Log in manually in the controlled browser to confirm creator access works.","Check the detail suffix (msg/HTTP status) for the precise rejection reason.","Clear stale cookies for the xiaohongshu.com domain and log in fresh.","Retry later if XHS imposed a temporary risk-control block."],"exampleFix":"// before\nconst identity = await verifyXhsIdentity(page); // throws if not logged in\n// after\nif (!await hasXhsSessionCookies(page)) {\n  await runLogin('creator.xiaohongshu.com');\n}\nconst identity = await verifyXhsIdentity(page);","handlingStrategy":"try-catch","validationCode":"// verify creator session before identity checks\nconst hasCookies = await hasXhsSessionCookies(page);\nif (!hasCookies) await runLogin('creator.xiaohongshu.com');","typeGuard":null,"tryCatchPattern":"try {\n  const identity = await verifyXhsIdentity(page);\n  return identity;\n} catch (e) {\n  if (e instanceof AuthRequiredError || /requires login/.test(e.message)) {\n    await runLogin('creator.xiaohongshu.com');\n    return verifyXhsIdentity(page);\n  }\n  throw e;\n}","preventionTips":["Log in to creator.xiaohongshu.com specifically, not just the main site.","Refresh creator sessions before long automation runs.","Watch for msg/HTTP-status details in the error to distinguish risk-control from expiry.","Avoid datacenter IPs that trigger XHS risk control."],"tags":["auth","xiaohongshu","session-expired","login"],"backgroundTag":"auth-required-login-expired","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}