jackwener/OpenCLI · error · AuthRequiredError
${probe.detail}
Error message
${probe.detail} What it means
When the in-page probe executed by verifyUpworkIdentity reports kind === 'auth', the code rethrows AuthRequiredError using the probe's own detail message. This means the page-level script detected Upwork redirected or presented a login/auth wall despite cookies existing.
Source
Thrown at clis/upwork/auth.js:35
(() => {
if (/\\/(ab|account-security\\/login|signup)\\//.test(location.pathname)) {
return { kind: 'auth', detail: 'Upwork redirected to login flow' };
}
const nuxt = (typeof window !== 'undefined' && window.__NUXT__) ? window.__NUXT__ : null;
const state = nuxt && (nuxt.state || (nuxt.data && nuxt.data[0]));
const user = state && (state.user || (state.auth && state.auth.user));
const profile = user && (user.profile || user);
if (!profile || !profile.id) {
return { kind: 'auth', detail: 'Upwork __NUXT__ has no profile id — anonymous' };
}
return {
ok: true,
user_id: String(profile.id || profile.uid || ''),
ciphertext: String(profile.ciphertext || ''),
};
})()
`);
if (probe?.kind === 'auth') throw new AuthRequiredError('upwork.com', probe.detail);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected Upwork probe: ${JSON.stringify(probe)}`);
return { user_id: probe.user_id, ciphertext: probe.ciphertext };
}
registerSiteAuthCommands({
site: 'upwork',
domain: 'upwork.com',
loginUrl: 'https://www.upwork.com/ab/account-security/login',
columns: ['user_id', 'ciphertext'],
quickCheck: hasUpworkSessionCookie,
verify: verifyUpworkIdentity,
poll: async (page) => {
if (!await hasUpworkSessionCookie(page)) {
throw new AuthRequiredError('upwork.com', 'Waiting for Upwork session cookies');
}
return verifyUpworkIdentity(page);
},
});View on GitHub (pinned to 49907e53dc)
Solutions
- Log in to upwork.com again in the connected browser to refresh the stale session, then retry.
- Clear upwork.com cookies and perform a fresh login so XSRF/user_uid/master token are consistent.
- Run the library's interactive login flow for upwork.com instead of relying on leftover cookies.
- Retry after confirming https://www.upwork.com/nx/find-work/ loads without redirecting to a login page.
Defensive patterns
Strategy: try-catch
Validate before calling
const cookies = await page.cookies('https://www.upwork.com');
if (!hasUpworkSessionCookie(cookies)) throw new Error('No Upwork cookies — log in first');
await page.goto('https://www.upwork.com/nx/find-work/');
if (/\/(ab|account-security\/login|signup)\//.test(new URL(page.url()).pathname)) throw new Error('Session dead — re-authenticate'); Type guard
function isAuthProbe(p) { return !!p && typeof p === 'object' && p.kind === 'auth'; } Try / catch
try {
await verifyUpworkIdentity(page);
} catch (e) {
if (e instanceof AuthRequiredError) {
await clearUpworkCookies(page); // stale cookies that no longer authenticate
await runInteractiveLogin(page);
} else throw e;
} Prevention
- Treat existing-but-stale cookies as expired: re-login when identity verification fails.
- Validate the session by loading /nx/find-work/ and checking for login redirects before commands.
- Don't reuse cookie jars across long periods; refresh before job runs.
- Clear Upwork cookies fully before re-authenticating to avoid mixed token states.
When it happens
Trigger: hasUpworkSessionCookie passed (cookies exist) but the page.evaluate probe detects location.pathname matching login/signup/account-security routes or profile lookup fails with an auth-kind result — stale or invalid cookies that still exist but no longer authenticate.
Common situations: Upwork invalidated the session server-side (cookies present but dead); session rotated and old tokens rejected; partial cookie state after a logout; Upwork A/B routing to /ab/ paths for unauthenticated users.
Related errors
- 请先在共享 Chrome 完成 1688 登录/验证,再重试(${action})
- Bilibili ${label} API requires login or permission: ${messag
- bilibili.com
- ${probe.detail}
- result.detail (auth required from Claude probe)
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/3213a2dd41a756da.
Report an issue: GitHub.