jackwener/OpenCLI · warning · AuthRequiredError
Waiting for Zhihu z_c0 cookie
Error message
Waiting for Zhihu z_c0 cookie
What it means
The zhihu login flow polls the browser until authentication completes; its poll function re-checks for the z_c0 cookie and, if still absent, throws AuthRequiredError 'Waiting for Zhihu z_c0 cookie'. It signals that the user has not finished signing in yet and polling should continue/await login.
Source
Thrown at clis/zhihu/auth.js:55
throw new AuthRequiredError('www.zhihu.com', 'Zhihu /api/v4/me returned no url_token — anonymous session');
}
return {
url_token: String(data.url_token),
name: String(data.name ?? ''),
uid: String(data.uid ?? data.id ?? ''),
};
}
registerSiteAuthCommands({
site: 'zhihu',
domain: 'www.zhihu.com',
loginUrl: 'https://www.zhihu.com/signin',
columns: ['url_token', 'name', 'uid'],
quickCheck: hasZhihuAuthCookie,
verify: verifyZhihuIdentity,
poll: async (page) => {
if (!await hasZhihuAuthCookie(page)) {
throw new AuthRequiredError('www.zhihu.com', 'Waiting for Zhihu z_c0 cookie');
}
return verifyZhihuIdentity(page);
},
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Complete the login in the automated browser window (scan QR / enter code) — the error clears on the next successful poll.
- If the login form shows a captcha or verification challenge, solve it in the browser.
- If polling repeatedly fails after successful sign-in, check that the profile persists cookies (user-data-dir) and the URL scope is www.zhihu.com.
- Treat this error as 'not yet logged in' — retry/poll rather than treating it as fatal, unless it persists.
Example fix
// before
await zhihuLogin(); // AuthRequiredError: Waiting for Zhihu z_c0 cookie
// after
try {
await zhihuLogin({ timeoutMs: 120_000 }); // give user time to scan QR
} catch (e) {
if (String(e.message).includes('z_c0')) {
console.error('Sign-in not completed in time. Re-run and finish login in the browser.');
}
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
const cookies = await page.getCookies({ url: 'https://www.zhihu.com' });
const done = cookies.some(c => c.name === 'z_c0' && c.value);
if (!done) console.log('Waiting for you to complete sign-in in the browser...'); Type guard
function loginComplete(cookies) { return Array.isArray(cookies) && cookies.some(c => c.name === 'z_c0' && !!c.value); } Try / catch
let me;
while (!me) {
try { me = await poll(); }
catch (e) { if (!String(e.message).includes('z_c0')) throw e; await sleep(1500); } // keep waiting for login
} Prevention
- Complete the QR/SMS sign-in promptly inside the automated browser
- Use a generous login timeout (e.g. 2 minutes) when a human must interact
- Solve any captcha/verification challenge shown during login
- Ensure cookies persist (user-data-dir) so login completes across polls
When it happens
Trigger: During interactive login, each poll fires before the user completes the sign-in (QR scan, SMS code, password) — the cookie is simply not set yet. Also fires if login silently failed (user closed the form, wrong credentials, captcha not solved).
Common situations: User takes too long to scan the QR code; Zhihu shows a captcha or verification step that blocks completion; automation profile blocked from persisting cookies so login never 'sticks'.
Related errors
- Zhihu z_c0 cookie missing — anonymous
- Band band_session cookie missing
- Waiting for Bilibili session cookies
- Bilibili creator-center login is required: ${message}
- Waiting for Boss wt2 / t cookies
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/96f8d204c0477abb.
Report an issue: GitHub.