jackwener/OpenCLI · warning · AuthRequiredError

Waiting for TikTok session cookies

Error message

Waiting for TikTok session cookies

What it means

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.

Source

Thrown at clis/tiktok/auth.js:61

      return null;
    })()
  `);
  if (!info?.sec_uid) {
    throw new AuthRequiredError('www.tiktok.com', 'TikTok universal data has no owner user — identity not rehydrated');
  }
  return { sec_uid: info.sec_uid, username: info.username, nickname: info.nickname };
}

registerSiteAuthCommands({
  site: 'tiktok',
  domain: 'tiktok.com',
  loginUrl: 'https://www.tiktok.com/login',
  columns: ['sec_uid', 'username', 'nickname'],
  quickCheck: hasTiktokSessionCookie,
  verify: verifyTiktokIdentity,
  poll: async (page) => {
    if (!await hasTiktokSessionCookie(page)) {
      throw new AuthRequiredError('www.tiktok.com', 'Waiting for TikTok session cookies');
    }
    return verifyTiktokIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Complete the TikTok login (including captcha/2FA) in the opened browser window and stay on a tiktok.com page until polling succeeds.
  2. Confirm the browser window being used for login is the same profile the CLI watches (same user-data-dir).
  3. 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.
  4. Restart `tiktok auth login` if the flow stalled — repeated polls with no progress indicate the login did not go through.
Defensive patterns

Strategy: retry

Validate before calling

// keep polling only while the login window is open and cookies are absent
while (!hasTiktokSession(await page.cookies('https://www.tiktok.com')) && Date.now() < deadline) {
  await sleep(1000); // poll until user completes login
}

Type guard

function hasTiktokSession(cookies) {
  const names = new Set(cookies.map(c => c.name));
  return names.has('sessionid') || names.has('sid_tt') || names.has('uid_tt');
}

Try / catch

try {
  return await tiktokAuth.loginWithPolling({ timeoutMs: 120000 });
} catch (e) {
  if (e instanceof AuthRequiredError && /Waiting for TikTok session cookies/.test(e.message)) {
    console.error('Login not completed in time — run tiktok auth login again and finish the flow.');
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/a17691ea3b5d111e. Report an issue: GitHub.