jackwener/OpenCLI · error · AuthRequiredError
quark.cn
Error message
quark.cn
What it means
verifyQuarkIdentity navigates to https://pan.quark.cn/ and runs WHOAMI_PROBE against Quark's account/info endpoint. When the probe classifies the response as kind='auth' (not logged in / missing auth cookies), it throws AuthRequiredError('quark.cn', detail), telling the caller that Quark requires interactive login before any command can proceed.
Source
Thrown at clis/quark/auth.js:28
if (r.status === 401 || r.status === 403) return { kind: 'auth', detail: 'Quark account/info HTTP ' + r.status };
if (!r.ok) return { kind: 'http', httpStatus: r.status };
const d = await r.json();
const data = d && d.data;
const isEmpty = !data || Array.isArray(data) || Object.keys(data).length === 0;
if (isEmpty) return { kind: 'auth', detail: 'Quark account/info returned empty data — anonymous' };
const nickname = String(data.nickname || data.nick_name || data.name || '');
if (!nickname) return { kind: 'render-error', detail: 'Quark account/info populated but no nickname field — response shape drift' };
return { ok: true, nickname };
} catch (e) {
return { kind: 'exception', detail: String(e && e.message || e) };
}
})()`;
async function verifyQuarkIdentity(page) {
await page.goto('https://pan.quark.cn/');
await page.wait(2);
const probe = await page.evaluate(WHOAMI_PROBE);
if (probe?.kind === 'auth') throw new AuthRequiredError('quark.cn', probe.detail);
if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Quark account/info`);
if (probe?.kind === 'render-error') throw new CommandExecutionError(probe.detail);
if (probe?.kind === 'exception') throw new CommandExecutionError(`Quark whoami failed: ${probe.detail}`);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Quark probe: ${JSON.stringify(probe)}`);
return { nickname: probe.nickname };
}
registerSiteAuthCommands({
site: 'quark',
domain: 'quark.cn',
loginUrl: 'https://pan.quark.cn/',
columns: ['nickname'],
verify: verifyQuarkIdentity,
poll: async (page) => {
const probe = await page.evaluate(WHOAMI_PROBE);
if (!probe?.ok) throw new AuthRequiredError('quark.cn', 'Waiting for Quark login');
return { nickname: probe.nickname };
},View on GitHub (pinned to 49907e53dc)
Solutions
- Open the browser profile used by the tool, log in to pan.quark.cn manually, then re-run the command.
- Run the quark login/auth command for this library to capture fresh credentials.
- Clear stale cookies and re-authenticate if the session is half-expired.
- Verify pan.quark.cn is reachable and not redirecting to a captcha/security check that breaks the session.
- If automation is headless, first perform the login step interactively in the same profile.
Example fix
// before opencli quark ls // -> AuthRequiredError: quark.cn // after: authenticate first opencli quark login # complete login in the browser opencli quark ls
Defensive patterns
Strategy: try-catch
Validate before calling
// Check for a live Quark session before running commands
async function hasQuarkSession(page) {
await page.goto('https://pan.quark.cn/');
await page.wait(2);
const probe = await page.evaluate(WHOAMI_PROBE); // or a lightweight cookie check
return probe?.ok === true;
}
if (!(await hasQuarkSession(page))) {
console.error('Quark session missing — run the login step first.');
} Type guard
function isAuthRequiredError(err) {
return err instanceof Error && (err.name === 'AuthRequiredError' || /auth required/i.test(String(err.message)));
} Try / catch
try {
await cli.run(['quark', 'ls']);
} catch (e) {
if (isAuthRequiredError(e)) {
await cli.run(['quark', 'login']); // interactive login in the shared profile
await cli.run(['quark', 'ls']); // retry
} else throw e;
} Prevention
- Log in to pan.quark.cn in the browser profile the tool uses before automating
- Re-authenticate periodically; Quark sessions expire after inactivity
- Never share one profile between interactive logout testing and automation
- Probe account/info (or check session cookies) before batch operations
When it happens
Trigger: Running any quark command when the browser profile has no valid Quark session cookies, the session expired, the account/info endpoint returns an auth-required payload, or the probe detects the login page instead of the logged-in drive UI.
Common situations: Using a fresh browser profile with no prior quark.cn login; Quark session cookies expired after inactivity; logging out in the shared browser profile; Quark invalidating sessions after a password change or security check; running in an environment where the login cookie was never captured.
Related errors
- Bilibili ${label} API requires login or permission: ${messag
- bilibili.com
- result.detail (auth required from Claude probe)
- auth
- Taobao tracknick cookie missing — anonymous
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/9bb012f649227296.
Report an issue: GitHub.