{"record":{"id":"eff520f231078ca3","repo":"jackwener/OpenCLI","slug":"upwork-redirected-to-login-open-https-www-upwor-eff520","errorCode":null,"errorMessage":"Upwork redirected to login. Open https://www.upwork.com in the connected browser and sign in, then retry.","messagePattern":"Upwork redirected to login\\. Open https://www\\.upwork\\.com in the connected browser and sign in, then retry\\.","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/upwork/search.js","lineNumber":88,"sourceCode":"                const challenge = (document.title || '').toLowerCase().includes('just a moment') || !!document.querySelector('[id^=\"cf-\"]');\n                const state = window.__NUXT__ && window.__NUXT__.state && window.__NUXT__.state.jobsSearch;\n                return {\n                    ready,\n                    onLogin,\n                    challenge,\n                    jobsPresent: !!(state && Object.prototype.hasOwnProperty.call(state, 'jobs')),\n                    jobs: state ? state.jobs : undefined,\n                    paging: state && state.paging ? state.paging : null,\n                    status: state ? state.status : null,\n                };\n            })()`));\n        }\n        catch (e) {\n            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.');\n        }\n\n        if (payload?.onLogin) {\n            throw new AuthRequiredError('upwork.com', 'Upwork redirected to login. Open https://www.upwork.com in the connected browser and sign in, then retry.');\n        }\n        if (payload?.challenge) {\n            throw new CommandExecutionError('Upwork served a Cloudflare challenge page', 'Open https://www.upwork.com in the connected browser and clear the challenge, then retry.');\n        }\n        if (!payload?.ready) {\n            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.');\n        }\n        if (!isPlainObject(payload)) {\n            throw new CommandExecutionError('Upwork search returned an unexpected Browser Bridge payload shape');\n        }\n        if (!payload.jobsPresent || !Array.isArray(payload.jobs)) {\n            throw new CommandExecutionError('Upwork search state had an unexpected jobs shape; expected window.__NUXT__.state.jobsSearch.jobs to be an array.');\n        }\n\n        const jobs = payload.jobs;\n        if (jobs.length === 0) {\n            throw new EmptyResultError('upwork search', `No Upwork jobs matched \"${query}\"${location ? ` in ${location}` : ''}`);\n        }","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/upwork/search.js#L70-L106","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Open https://www.upwork.com in the connected browser and sign in manually.","Re-run the search command after confirming the browser shows the logged-in Upwork UI.","If using a dedicated automation profile, log that profile in and keep the session cookie alive.","Check that you are not switching browser profiles between sessions, which loses cookies."],"exampleFix":"// before\nawait cli.search('react developer') // AuthRequiredError: redirected to login\n// after\nawait openBrowser('https://www.upwork.com'); await signInManually(); // then retry\nawait cli.search('react developer')","handlingStrategy":"try-catch","validationCode":"// verify a session exists before running the command\nconst loggedIn = await bridge.eval(() =>\n  !!document.querySelector('[data-test=\"UployaMenu-profile\"], a[href*=\"logout\"]'));\nif (!loggedIn) throw new Error('Sign in to upwork.com in the connected browser first');","typeGuard":"function isAuthRequiredError(e) {\n  return e instanceof Error && e.name === 'AuthRequiredError';\n}","tryCatchPattern":"try {\n  rows = await cli.search(query);\n} catch (e) {\n  if (isAuthRequiredError(e)) {\n    await openBrowser('https://www.upwork.com'); // user signs in interactively\n    rows = await cli.search(query); // retry once after sign-in\n  } else throw e;\n}","preventionTips":["Sign in to Upwork in the dedicated automation browser profile and keep that profile warm.","Periodically visit upwork.com manually to refresh the session cookie.","Avoid switching browser profiles or clearing cookies between runs.","Catch AuthRequiredError explicitly and prompt for interactive sign-in rather than failing silently."],"tags":["authentication","upwork","browser-automation","session-expired"],"backgroundTag":"upwork-login-redirect","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}