jackwener/OpenCLI · error · AuthRequiredError

ChatGPT project requires a logged-in ChatGPT session.

Error message

ChatGPT project requires a logged-in ChatGPT session.

What it means

AuthRequiredError thrown while opening a ChatGPT project: the page state shows a login gate or a logged-out session, so the library cannot proceed and demands a logged-in session for the target ChatGPT domain.

Source

Thrown at clis/chatgpt/utils.js:2943

    '[data-testid*="project-files"] input[type="file"]',
    '[data-testid*="project"] input[type="file"]',
];

/**
 * Navigate to a ChatGPT project page.
 */
export async function navigateToProject(page, projectId) {
    const id = parseChatGPTProjectId(projectId);
    await page.goto(`${CHATGPT_URL}/g/g-p-${id}`, { settleMs: 2000 });
    try {
        await page.wait({ selector: COMPOSER_WAIT_SELECTOR, timeout: 10 });
    } catch {
        // Composer may not mount if project requires login; downstream ensureChatGPTLogin handles it.
    }
    const state = await getPageState(page);
    if (projectIdFromUrl(state.url) === id) return id;
    if (state.hasLoginGate || !state.isLoggedIn) {
        throw new AuthRequiredError(CHATGPT_DOMAIN, 'ChatGPT project requires a logged-in ChatGPT session.');
    }
    throw new CommandExecutionError(
        `ChatGPT did not open the requested project ${id}.`,
        `Current URL: ${state.url || '(unknown)'}`,
    );
}

/**
 * Open the Project knowledge files dialog by clicking the "Add files" button
 * in the project header area (NOT the chat composer's plus button).
 * Returns true if the dialog appeared.
 */
export async function openProjectKnowledgeDialog(page) {
    const rawOpenResult = unwrapEvaluateResult(await page.evaluate(`
        (() => {
            const labels = ${JSON.stringify(PROJECT_ADD_FILES_LABELS)};
            const isVisible = (el) => {
                if (!(el instanceof HTMLElement)) return false;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Run the library's login flow (ensureChatGPTLogin) or log into ChatGPT in the automation browser profile, then retry
  2. Persist a logged-in profile/storage state so sessions survive restarts
  3. Check that the correct domain/profile is used (CHATGPT_DOMAIN) and cookies are not isolated per context
  4. Re-check plan/entitlements if login succeeds but projects remain gated

Example fix

// before
await openChatGPTProject(page, projectId);
// after
await ensureChatGPTLogin(page, CHATGPT_DOMAIN);
await openChatGPTProject(page, projectId);
Defensive patterns

Strategy: try-catch

Validate before calling

const state = await getPageState(page);
if (state.hasLoginGate || !state.isLoggedIn) {
  await ensureChatGPTLogin(page, CHATGPT_DOMAIN);
}

Type guard

function isLoggedIn(state) { return !!state && state.isLoggedIn === true && !state.hasLoginGate; }

Try / catch

try {
  await openChatGPTProject(page, projectId);
} catch (e) {
  if (e instanceof AuthRequiredError) {
    await ensureChatGPTLogin(page, CHATGPT_DOMAIN);
    await openChatGPTProject(page, projectId);
  } else throw e;
}

Prevention

When it happens

Trigger: openChatGPTProject/verify flow called getPageState after loading the project, and state.hasLoginGate is true or state.isLoggedIn is false — the browser session has no valid ChatGPT auth cookies.

Common situations: Session expired between runs; running headless with a fresh profile that was never logged in; cookies cleared or ChatGPT logged the device out; project features requiring a plan the anonymous session lacks.

Related errors


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