{"record":{"id":"a17691ea3b5d111e","repo":"jackwener/OpenCLI","slug":"waiting-for-tiktok-session-cookies","errorCode":null,"errorMessage":"Waiting for TikTok session cookies","messagePattern":"Waiting for TikTok session cookies","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"warning","filePath":"clis/tiktok/auth.js","lineNumber":61,"sourceCode":"      return null;\n    })()\n  `);\n  if (!info?.sec_uid) {\n    throw new AuthRequiredError('www.tiktok.com', 'TikTok universal data has no owner user — identity not rehydrated');\n  }\n  return { sec_uid: info.sec_uid, username: info.username, nickname: info.nickname };\n}\n\nregisterSiteAuthCommands({\n  site: 'tiktok',\n  domain: 'tiktok.com',\n  loginUrl: 'https://www.tiktok.com/login',\n  columns: ['sec_uid', 'username', 'nickname'],\n  quickCheck: hasTiktokSessionCookie,\n  verify: verifyTiktokIdentity,\n  poll: async (page) => {\n    if (!await hasTiktokSessionCookie(page)) {\n      throw new AuthRequiredError('www.tiktok.com', 'Waiting for TikTok session cookies');\n    }\n    return verifyTiktokIdentity(page);\n  },\n});\n","sourceCodeStart":43,"sourceCodeEnd":66,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/tiktok/auth.js#L43-L66","documentation":"The `tiktok auth` command's `poll` function is invoked repeatedly while the CLI waits for the user to finish logging in. If `hasTiktokSessionCookie` still finds none of `sessionid`/`sid_tt`/`uid_tt`, it throws AuthRequiredError('Waiting for TikTok session cookies') to signal 'not logged in yet' for that poll iteration. It is an expected intermediate state during the interactive login flow, not necessarily a terminal failure.","triggerScenarios":"During `tiktok auth login`, each poll tick where the browser still has no TikTok session cookies: the user hasn't completed login, the login page blocked automation, cookies are being written to a different profile, or the login failed outright.","commonSituations":"User abandoned or slow-walked the login; TikTok served a captcha/QR-only flow that never sets cookies; the CLI watches one profile while the user logs in via another browser; VPN/region redirecting to an app-download wall instead of the login form.","solutions":["Complete the TikTok login (including captcha/2FA) in the opened browser window and stay on a tiktok.com page until polling succeeds.","Confirm the browser window being used for login is the same profile the CLI watches (same user-data-dir).","If the login page never sets cookies, disable automation fingerprints (headed mode, real user agent) or log in manually in a normal browser session with that profile.","Restart `tiktok auth login` if the flow stalled — repeated polls with no progress indicate the login did not go through."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// keep polling only while the login window is open and cookies are absent\nwhile (!hasTiktokSession(await page.cookies('https://www.tiktok.com')) && Date.now() < deadline) {\n  await sleep(1000); // poll until user completes login\n}","typeGuard":"function hasTiktokSession(cookies) {\n  const names = new Set(cookies.map(c => c.name));\n  return names.has('sessionid') || names.has('sid_tt') || names.has('uid_tt');\n}","tryCatchPattern":"try {\n  return await tiktokAuth.loginWithPolling({ timeoutMs: 120000 });\n} catch (e) {\n  if (e instanceof AuthRequiredError && /Waiting for TikTok session cookies/.test(e.message)) {\n    console.error('Login not completed in time — run tiktok auth login again and finish the flow.');\n  }\n  throw e;\n}","preventionTips":["Set a generous polling timeout and clear user instructions to finish login + captcha.","Ensure the login browser and the polled session share the same profile/user-data-dir.","Use headed mode so captchas and QR flows can be completed by a human.","Detect repeated identical poll failures and abort early with guidance instead of looping."],"tags":["tiktok","auth","login-polling","cookies"],"backgroundTag":"auth-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}