jackwener/OpenCLI · error · AuthRequiredError

Upwork redirected to login. Open https://www.upwork.com in t

Error message

Upwork redirected to login. Open https://www.upwork.com in the connected browser and sign in, then retry.

What it means

`upwork feed` requires an authenticated Upwork session. The in-page probe detects that the browser was redirected to Upwork's login page (paths /ab/account-security/login or /nx/login) instead of the feed, and throws AuthRequiredError naming upwork.com. This means the cookies in the connected browser are missing, expired, or invalid.

Source

Thrown at clis/upwork/feed.js:83

                const onLogin = /\\/(ab\\/account-security\\/login|nx\\/login)/.test(location.pathname);
                const challenge = (document.title || '').toLowerCase().includes('just a moment') || !!document.querySelector('[id^="cf-"]');
                const state = window.__NUXT__ && window.__NUXT__.state && window.__NUXT__.state[key];
                return {
                    ready,
                    onLogin,
                    challenge,
                    jobsPresent: !!(state && Object.prototype.hasOwnProperty.call(state, 'jobs')),
                    jobs: state ? state.jobs : undefined,
                    paging: state && state.paging ? state.paging : null,
                };
            })()`));
        }
        catch (e) {
            throw new CommandExecutionError(`Failed to read Upwork feed state: ${e?.message ?? e}`, 'The Nuxt state global was not reachable; try again after opening Upwork in the connected browser.');
        }

        if (payload?.onLogin) {
            throw new AuthRequiredError('upwork.com', 'Upwork redirected to login. Open https://www.upwork.com in the connected browser and sign in, then retry.');
        }
        if (payload?.challenge) {
            throw new CommandExecutionError('Upwork served a Cloudflare challenge page', 'Open https://www.upwork.com in the connected browser and clear the challenge, then retry.');
        }
        if (!payload?.ready) {
            throw new CommandExecutionError(`Upwork feed state (window.__NUXT__.state.${stateKey}) was not present within 15s`, 'The page may not have finished hydrating, or the SSR state shape may have changed.');
        }
        if (!isPlainObject(payload)) {
            throw new CommandExecutionError('Upwork feed returned an unexpected Browser Bridge payload shape');
        }
        if (!payload.jobsPresent || !Array.isArray(payload.jobs)) {
            throw new CommandExecutionError(`Upwork feed state had an unexpected jobs shape; expected window.__NUXT__.state.${stateKey}.jobs to be an array.`);
        }

        const jobs = payload.jobs;
        if (jobs.length === 0) {
            throw new EmptyResultError(`upwork feed ${tab}`, `Upwork ${tab} feed is empty for the current account`);
        }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open https://www.upwork.com in the connected browser and sign in manually, then re-run the command.
  2. Verify the browser profile the CLI uses is the one where you logged in (cookie strategy depends on that profile's session cookies).
  3. If sessions keep expiring, check whether Upwork flags the environment (new IP, headless signals) and complete any security verification.
  4. Automate a pre-check: probe a page that requires auth before running batch jobs, and pause with a clear message when AuthRequiredError is thrown.

Example fix

// before
const jobs = await upwork.feed();  // AuthRequiredError when session expired
// after
try {
  const jobs = await upwork.feed();
} catch (e) {
  if (e instanceof AuthRequiredError) {
    console.error('Sign in at https://www.upwork.com in the connected browser, then rerun.');
    process.exitCode = 2;
  } else throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight auth check: hit a members-only URL and see if it redirects to /nx/login
const redirected = await bridge.currentUrlStartsWith('https://www.upwork.com/ab/account-security/login');
if (redirected) promptUserToSignIn();

Try / catch

import { AuthRequiredError } from '@jackwener/opencli/errors';
try {
  const jobs = await upwork.feed();
} catch (e) {
  if (e instanceof AuthRequiredError) {
    console.error('Sign in to upwork.com in the connected browser, then retry.');
    return null; // don't treat as a crash
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `upwork feed` (or `upwork feed most-recent`) when the connected browser has no valid Upwork session: never logged in, session cookie expired, cookies cleared, or the cookie-sync strategy failed so Upwork bounces the feed URL to its login/onboarding flow.

Common situations: Session expired after a period of inactivity; user logged out or cleared cookies in the shared browser profile; running from a CI/machine whose browser profile was never authenticated; Upwork forcing re-authentication after a security event or password change.

Related errors


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