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

  1. Log in to upwork.com again in the connected browser to refresh the stale session, then retry.
  2. Clear upwork.com cookies and perform a fresh login so XSRF/user_uid/master token are consistent.
  3. Run the library's interactive login flow for upwork.com instead of relying on leftover cookies.
  4. 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

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/3213a2dd41a756da. Report an issue: GitHub.