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

An AuthRequiredError raised because the Upwork page the Browser Bridge evaluated redirected to the login flow (payload.onLogin was true). It means the connected browser has no valid Upwork session, so the search state cannot be read. The library detects the redirect inside the page script and surfaces it as an auth problem rather than a generic failure.

Source

Thrown at clis/upwork/search.js:88

                const challenge = (document.title || '').toLowerCase().includes('just a moment') || !!document.querySelector('[id^="cf-"]');
                const state = window.__NUXT__ && window.__NUXT__.state && window.__NUXT__.state.jobsSearch;
                return {
                    ready,
                    onLogin,
                    challenge,
                    jobsPresent: !!(state && Object.prototype.hasOwnProperty.call(state, 'jobs')),
                    jobs: state ? state.jobs : undefined,
                    paging: state && state.paging ? state.paging : null,
                    status: state ? state.status : null,
                };
            })()`));
        }
        catch (e) {
            throw new CommandExecutionError(`Failed to read Upwork search 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 search state (window.__NUXT__.state.jobsSearch) 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 search returned an unexpected Browser Bridge payload shape');
        }
        if (!payload.jobsPresent || !Array.isArray(payload.jobs)) {
            throw new CommandExecutionError('Upwork search state had an unexpected jobs shape; expected window.__NUXT__.state.jobsSearch.jobs to be an array.');
        }

        const jobs = payload.jobs;
        if (jobs.length === 0) {
            throw new EmptyResultError('upwork search', `No Upwork jobs matched "${query}"${location ? ` in ${location}` : ''}`);
        }

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open https://www.upwork.com in the connected browser and sign in manually.
  2. Re-run the search command after confirming the browser shows the logged-in Upwork UI.
  3. If using a dedicated automation profile, log that profile in and keep the session cookie alive.
  4. Check that you are not switching browser profiles between sessions, which loses cookies.

Example fix

// before
await cli.search('react developer') // AuthRequiredError: redirected to login
// after
await openBrowser('https://www.upwork.com'); await signInManually(); // then retry
await cli.search('react developer')
Defensive patterns

Strategy: try-catch

Validate before calling

// verify a session exists before running the command
const loggedIn = await bridge.eval(() =>
  !!document.querySelector('[data-test="UployaMenu-profile"], a[href*="logout"]'));
if (!loggedIn) throw new Error('Sign in to upwork.com in the connected browser first');

Type guard

function isAuthRequiredError(e) {
  return e instanceof Error && e.name === 'AuthRequiredError';
}

Try / catch

try {
  rows = await cli.search(query);
} catch (e) {
  if (isAuthRequiredError(e)) {
    await openBrowser('https://www.upwork.com'); // user signs in interactively
    rows = await cli.search(query); // retry once after sign-in
  } else throw e;
}

Prevention

When it happens

Trigger: Running the upwork search command while the connected browser's Upwork cookies are expired or missing, causing https://www.upwork.com to 302 to the sign-in page which the in-page detection flags as onLogin.

Common situations: Session expired after weeks away; user logged out of Upwork in that browser profile; using a fresh/incognito browser profile with no cookies; Upwork invalidated the session after a security event; VPN/IP change forced re-authentication.

Related errors


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