jackwener/OpenCLI · error · AuthRequiredError
Taobao tracknick cookie missing — anonymous
Error message
Taobao tracknick cookie missing — anonymous
What it means
verifyTaobaoIdentity first checks the browser cookie jar for a non-empty `tracknick` cookie on www.taobao.com — Taobao's marker of an authenticated session. If absent, it throws AuthRequiredError ('taobao.com') because the session is anonymous and identity cannot be verified.
Source
Thrown at clis/taobao/auth.js:11
import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
import { registerSiteAuthCommands } from '../_shared/site-auth.js';
async function hasTaobaoSessionCookie(page) {
const cookies = await page.getCookies({ url: 'https://www.taobao.com' });
return cookies.some(c => c.name === 'tracknick' && c.value);
}
async function verifyTaobaoIdentity(page) {
if (!await hasTaobaoSessionCookie(page)) {
throw new AuthRequiredError('taobao.com', 'Taobao tracknick cookie missing — anonymous');
}
await page.goto('https://i.taobao.com/my_itaobao');
await page.wait(2);
const finalUrl = await page.evaluate(`location.href`);
if (/login\.taobao\.com\/member\/login/.test(String(finalUrl || ''))) {
throw new AuthRequiredError('taobao.com', `Taobao my_itaobao redirected to login: ${finalUrl}`);
}
const cookies = await page.getCookies({ url: 'https://www.taobao.com' });
const tracknick = cookies.find(c => c.name === 'tracknick')?.value || '';
if (!tracknick) {
throw new AuthRequiredError('taobao.com', 'Taobao tracknick cookie absent after navigation');
}
const domInfo = await page.evaluate(`
(() => {
const nick = (document.querySelector('.user-nick, .site-nav-user, .user-name')?.innerText || '').trim();
const html = document.body?.innerHTML || '';
const userIdMatch = html.match(/userId[\"'\\s:=]+(\\d+)/i);
return { nickname: nick, user_id: userIdMatch?.[1] || '' };View on GitHub (pinned to 49907e53dc)
Solutions
- Run `taobao auth login` and complete login so the tracknick cookie is set.
- Confirm with `taobao auth status` that the quick check passes before running commands.
- Re-login if cookies expired; Taobao sessions do not last indefinitely.
- Ensure the CLI uses a persistent browser profile so cookies survive restarts.
Example fix
// before: assuming a session exists
const identity = await verifyTaobaoIdentity(page);
// after: pre-check and login when anonymous
const cookies = await page.getCookies({ url: 'https://www.taobao.com' });
if (!cookies.some(c => c.name === 'tracknick' && c.value)) {
await taobaoLogin(page);
}
const identity = await verifyTaobaoIdentity(page); Defensive patterns
Strategy: validation
Validate before calling
const cookies = await page.getCookies({ url: 'https://www.taobao.com' });
if (!cookies.some(c => c.name === 'tracknick' && c.value)) {
await taobaoLogin(page); // establish session before proceeding
} Type guard
function hasTaobaoSession(cookies) {
return cookies.some(c => c.name === 'tracknick' && !!c.value);
} Try / catch
try {
const identity = await verifyTaobaoIdentity(page);
} catch (e) {
if (e instanceof AuthRequiredError && /tracknick cookie missing/.test(e.message)) {
await taobaoLogin(page);
return verifyTaobaoIdentity(page);
}
throw e;
} Prevention
- Always run the auth quick-check before identity-dependent commands
- Keep cookies in a persistent profile
- Schedule re-login when sessions expire
When it happens
Trigger: page.getCookies({ url: 'https://www.taobao.com' }) contains no `tracknick` cookie with a value — never logged in on this profile, cookies expired/cleared, or the login flow never completed.
Common situations: Fresh automation profile; cookie expiry after Taobao's session TTL; user cleared cookies or used a different profile; corporate proxy blocking taobao.com cookie domains.
Related errors
- Taobao tracknick cookie absent after navigation
- Bilibili ${label} API requires login or permission: ${messag
- bilibili.com
- result.detail (auth required from Claude probe)
- auth
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b63d4e2b8d2436be.
Report an issue: GitHub.