jackwener/OpenCLI · error · AuthRequiredError
TikTok session cookies (sessionid/sid_tt/uid_tt) missing
Error message
TikTok session cookies (sessionid/sid_tt/uid_tt) missing
What it means
`verifyTiktokIdentity` first checks the browser's cookies for any of the TikTok session cookies `sessionid`, `sid_tt`, or `uid_tt`. If none is present it throws AuthRequiredError, because TikTok identity verification (reading the rehydration data for sec_uid/username/nickname) is only possible for a logged-in session. The library requires authentication before it can confirm whose session the browser holds.
Source
Thrown at clis/tiktok/auth.js:12
import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
import { registerSiteAuthCommands } from '../_shared/site-auth.js';
async function hasTiktokSessionCookie(page) {
const cookies = await page.getCookies({ url: 'https://www.tiktok.com' });
const names = new Set(cookies.map(c => c.name));
return names.has('sessionid') || names.has('sid_tt') || names.has('uid_tt');
}
async function verifyTiktokIdentity(page) {
if (!await hasTiktokSessionCookie(page)) {
throw new AuthRequiredError('www.tiktok.com', 'TikTok session cookies (sessionid/sid_tt/uid_tt) missing');
}
await page.goto('https://www.tiktok.com/foryou');
await page.wait(2);
const info = await page.evaluate(`
(() => {
const raw = document.querySelector('script[id="__UNIVERSAL_DATA_FOR_REHYDRATION__"]')?.textContent;
if (!raw) return null;
let data;
try { data = JSON.parse(raw); } catch { return null; }
const scope = data?.['__DEFAULT_SCOPE__'] || {};
const seen = new Set();
const stack = [scope];
while (stack.length) {
const node = stack.pop();
if (!node || typeof node !== 'object' || seen.has(node)) continue;
seen.add(node);
if (Array.isArray(node)) { stack.push(...node); continue; }
const u = node.user;View on GitHub (pinned to 49907e53dc)
Solutions
- Run the `tiktok auth login` flow and complete the login in the opened browser window so session cookies are stored.
- Verify you are using the intended browser profile/user-data-dir that contains the logged-in TikTok session.
- Log into tiktok.com manually in the same profile and confirm the session persists, then retry verification.
- Check cookie file access/permissions if the profile is logged in but cookies read as empty (e.g. missing volume mount).
Defensive patterns
Strategy: validation
Validate before calling
// ensure a logged-in TikTok profile exists before verification
const cookies = await page.cookies('https://www.tiktok.com');
const names = new Set(cookies.map(c => c.name));
if (!names.has('sessionid') && !names.has('sid_tt') && !names.has('uid_tt')) {
await runTiktokLoginFlow(); // or prompt the user to log in
} 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
import { AuthRequiredError } from '@jackwener/opencli/errors';
try {
return await tiktokAuth.verify(page);
} catch (e) {
if (e instanceof AuthRequiredError) {
await tiktokAuth.login(); // interactive login, then retry
return tiktokAuth.verify(page);
}
throw e;
} Prevention
- Always run the login flow before verification on fresh profiles.
- Mount/persist the correct user-data-dir so cookies survive container restarts.
- Check cookie presence proactively (quickCheck) before deep verification.
- Alert users to re-login when TikTok invalidates old sessions.
When it happens
Trigger: Calling `tiktok auth verify` (or any flow invoking verifyTiktokIdentity) against a browser profile that was never logged in, was logged out, or whose cookies were cleared; also triggered when the cookie store cannot be read so the cookie list is empty.
Common situations: Fresh headless browser profile with no login; expired TikTok session cookies purged by the browser; pointing the CLI at the wrong Chrome profile directory; running in a container without the profile volume mounted.
Related errors
- Chaoxing session cookies missing
- Claude sessionKey cookie missing
- Claude session incomplete — ajs_user_id cookie missing
- Google session cookies are missing
- LinkedIn JSESSIONID cookie not found. Please sign in to Link
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/5d05f1e976792da7.
Report an issue: GitHub.