jackwener/OpenCLI · error · AuthRequiredError
TikTok Studio item_list requires login (HTTP ${result.status
Error message
TikTok Studio item_list requires login (HTTP ${result.status}) What it means
The item_list endpoint answered with HTTP 401 or 403, meaning the session is not authorized to read Studio data. The library converts this into an AuthRequiredError for www.tiktok.com so callers can trigger a login flow rather than retrying blindly.
Source
Thrown at clis/tiktok/creator-videos.js:197
comments: normalizeNumber(item.comment_count),
saves: normalizeNumber(item.favorite_count),
shares: normalizeNumber(item.share_count),
url,
};
}
async function fetchCreatorVideosPage(page, cursor, size) {
const result = await page.evaluate(buildFetchItemListScript(buildItemListRequest(cursor, size))).catch((error) => {
throw new CommandExecutionError(`Failed to fetch TikTok Studio item_list: ${getErrorMessage(error)}`);
});
if (!result || typeof result !== 'object') {
throw new CommandExecutionError('TikTok Studio item_list returned an unreadable response');
}
if (result.networkError) {
throw new CommandExecutionError(`TikTok Studio item_list network failure: ${result.networkError}`);
}
if (result.status === 401 || result.status === 403) {
throw new AuthRequiredError('www.tiktok.com', `TikTok Studio item_list requires login (HTTP ${result.status})`);
}
if (!result.ok) {
const detail = result.parseError
? `invalid JSON (${result.parseError})`
: `HTTP ${result.status || 0}${result.statusText ? ` ${result.statusText}` : ''}`;
throw new CommandExecutionError(`TikTok Studio item_list failed: ${detail}`, result.text ? `Response preview: ${result.text}` : undefined);
}
const payload = unwrapPayload(result.data);
assertApiSuccess(payload);
return payload;
}
async function listCreatorVideos(page, args) {
const limit = requirePositiveInt(args.limit, 'limit', DEFAULT_LIMIT, MAX_LIMIT);
let nextCursor = requireCursor(args.cursor);
const rows = [];
let skippedMissingId = 0;
const pageSize = limit > SERVER_PAGE_MAX ? SERVER_PAGE_MAX : limit;View on GitHub (pinned to 49907e53dc)
Solutions
- Open TikTok Studio (www.tiktok.com) in the configured Chrome profile and log in / re-authenticate
- Verify the logged-in account actually owns or has access to the target creator's Studio data
- Clear stale tiktok.com cookies and log in again if re-auth alone doesn't help
- Catch AuthRequiredError in your automation and pause for interactive login before retrying
Example fix
// before
await listCreatorVideos(page, { limit: 20 });
// after
try {
rows = await listCreatorVideos(page, { limit: 20 });
} catch (e) {
if (e instanceof AuthRequiredError) { await promptUserLogin('www.tiktok.com'); rows = await listCreatorVideos(page, { limit: 20 }); }
else throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check login state
const loggedIn = await page.evaluate(() => !!document.querySelector('[data-e2e="profile-icon"], [data-e2e="nav-login"] ~ *'));
if (!loggedIn) throw new Error('Log in to TikTok Studio first'); Type guard
function isAuthError(e) { return e instanceof AuthRequiredError || /requires login/.test(e.message); } Try / catch
try {
rows = await listCreatorVideos(page, opts);
} catch (e) {
if (e instanceof AuthRequiredError) {
await interactiveLogin('www.tiktok.com'); // pause for manual login
rows = await listCreatorVideos(page, opts);
} else throw e;
} Prevention
- Log in to TikTok Studio in the configured profile before running commands
- Re-login when sessions expire; catch AuthRequiredError to trigger this automatically
- Confirm the logged-in account has access to the target Studio data
When it happens
Trigger: result.status is 401 or 403: the current Chrome profile's TikTok session cookie is missing, expired, or lacks Studio permissions for the requested account.
Common situations: TikTok session expired (cookies rotated/expired), using a profile that never logged in, logged into a different TikTok account than the Studio target, or TikTok invalidating sessions after suspicious activity.
Related errors
- 未登录或登录已过期,请先在浏览器中登录贝壳找房
- Gmail ${operation} returned HTTP ${status}
- LinkedIn Learning auth failed (HTTP ${result.status ?? ''}).
- LinkedIn Sales Navigator API auth failed (HTTP ' + (result.s
- Manus /api/auth/session HTTP ${r.status}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b7b5a61cf45233c2.
Report an issue: GitHub.