{"record":{"id":"50d2f065a8f4f649","repo":"jackwener/OpenCLI","slug":"waiting-for-doubao-login","errorCode":null,"errorMessage":"Waiting for Doubao login","messagePattern":"Waiting for Doubao login","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"info","filePath":"clis/doubao/auth.js","lineNumber":62,"sourceCode":"  site: 'doubao',\n  domain: 'www.doubao.com',\n  loginUrl: 'https://www.doubao.com/chat/',\n  columns: ['user_id', 'name'],\n  verify: verifyDoubaoIdentity,\n  // passport_csrf_token is set for anonymous sessions too, so a cookie gate\n  // would navigate away mid-login. Probe the account API on the current page\n  // (no goto) and only confirm once a real user_id is present.\n  poll: async (page) => {\n    const loggedIn = await page.evaluate(`(async () => {\n      try {\n        const r = await fetch('/passport/account/info/v2/', { credentials: 'include', headers: { Accept: 'application/json' } });\n        if (!r.ok) return false;\n        const d = await r.json();\n        return !!(d?.data?.user_id_str);\n      } catch { return false; }\n    })()`);\n    if (!loggedIn) {\n      throw new AuthRequiredError('www.doubao.com', 'Waiting for Doubao login');\n    }\n    return verifyDoubaoIdentity(page);\n  },\n});\n","sourceCodeStart":44,"sourceCodeEnd":67,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/doubao/auth.js#L44-L67","documentation":"During the interactive Doubao login flow, the CLI polls the page for a logged-in signal (d.data.user_id_str from the account check). As long as that signal is absent, it throws AuthRequiredError with this message so the driver keeps waiting for the user to log in. It is an expected state, not a bug: the browser session is simply not authenticated yet.","triggerScenarios":"waitForLogin's polled page.evaluate returns loggedIn=false because the user has not completed the Doubao login in the browser, the login page was closed early, or the response lacks data.user_id_str.","commonSituations":"User delays entering credentials/2FA; login page redirects somewhere the poller can't read; cookies cleared mid-flow; slow network leaving the check endpoint unanswered.","solutions":["Complete the Doubao login in the opened browser window and wait for the flow to continue","Keep the Doubao tab open until the CLI reports success","Check network connectivity if the page never finishes loading","Re-run the login command if the tab was closed or redirected"],"exampleFix":"// before (caller aborting on this error)\ntry { await login(); } catch (e) { console.error(e); }\n// after\ntry { await login(); } catch (e) {\n  if (!(e instanceof AuthRequiredError)) throw e; // keep waiting while login pending\n}","handlingStrategy":"retry","validationCode":"const r = await page.evaluate(async () => {\n  const d = await (await fetch('/passport/account/info/')).json();\n  return !!(d?.data?.user_id_str);\n});\nif (!r) console.log('Doubao login not yet complete; keep waiting');","typeGuard":"function isLoggedInPayload(d) { return typeof d?.data?.user_id_str === 'string' && d.data.user_id_str.length > 0; }","tryCatchPattern":"try {\n  await waitForLogin(page);\n} catch (e) {\n  if (e instanceof AuthRequiredError && e.message === 'Waiting for Doubao login') {\n    await waitForUserLoginWithTimeout(page, 120_000); // poll longer before giving up\n  } else throw e;\n}","preventionTips":["Keep the login tab open until the flow completes","Allow generous time for 2FA/captcha during login","Verify cookies persist between runs (non-incognito profile)","Warn users clearly that manual login action is required"],"tags":["doubao","auth","login-flow","waiting"],"backgroundTag":"auth-login-pending","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}