jackwener/OpenCLI · error · AuthRequiredError

ChatGPT requires a logged-in browser session.

Error message

ChatGPT requires a logged-in browser session.

What it means

ensureChatGPTLogin reads the page state and throws AuthRequiredError (domain chatgpt.com) when state.isLoggedIn is false or a login gate is present. All chatgpt read/detail/history/project commands funnel through it, so any unauthenticated browser session surfaces this message (or the command-specific override).

Source

Thrown at clis/chatgpt/utils.js:365

            const label = ((node.innerText || node.textContent || '') + ' ' + (node.getAttribute('aria-label') || '')).trim().toLowerCase();
            return isVisible(node) && /^(log in|login|sign up|sign in)$/.test(label);
        });
        const userMenu = document.querySelector('[data-testid="profile-button"], [aria-label*="Profile"], [aria-label*="Account"], button[id*="headlessui-menu-button"]');
        const hasLoginGate = !!loginLink || /log in to chatgpt|sign up to chatgpt|welcome to chatgpt/i.test(text);
        return {
            url: window.location.href,
            title: document.title,
            hasComposer,
            isLoggedIn: hasComposer || !!userMenu || !hasLoginGate,
            hasLoginGate,
        };
    })()`)), 'chatgpt page state');
}

export async function ensureChatGPTLogin(page, message = 'ChatGPT requires a logged-in browser session.') {
    const state = await getPageState(page);
    if (!state.isLoggedIn || state.hasLoginGate) {
        throw new AuthRequiredError(CHATGPT_DOMAIN, message);
    }
    return state;
}

export async function ensureChatGPTComposer(page, message = 'ChatGPT composer is not available on the current page.') {
    const state = await ensureChatGPTLogin(page, message);
    if (!state.hasComposer) {
        throw new CommandExecutionError(message);
    }
    return state;
}

function requireKnownChatGPTModel(model) {
    const key = String(model ?? '').trim().toLowerCase();
    const targetKey = CHATGPT_MODEL_ALIASES[key] || key;
    const option = CHATGPT_MODEL_TARGETS[targetKey];
    if (!option) {
        throw new ArgumentError(

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open the automation browser profile and log into chatgpt.com interactively once
  2. Reuse a persistent browser profile so the session cookie survives restarts
  3. Re-run the command after re-authenticating; the session check will pass
  4. Catch AuthRequiredError in wrappers and prompt the user to log in instead of retrying blindly

Example fix

// before
const state = await readCommand(...); // fresh profile, not logged in
// after
await launch({ persistent: true, userDataDir: './chrome-profile' });
// log into chatgpt.com once in that profile, then
const state = await readCommand(...);
Defensive patterns

Strategy: try-catch

Validate before calling

const state = await getPageState(page).catch(() => null);
const loggedIn = state?.isLoggedIn && !state?.hasLoginGate;

Type guard

function isLoggedInState(s) { return Boolean(s && s.isLoggedIn === true && s.hasLoginGate === false); }

Try / catch

try { await ensureChatGPTLogin(page); } catch (e) { if (e instanceof AuthRequiredError) { console.error('Log into chatgpt.com in the automation browser profile, then retry.'); process.exitCode = 3; } else throw e; }

Prevention

When it happens

Trigger: Running any chatgpt command while the automation browser has no logged-in chatgpt.com session, after the session cookie expired, in a fresh browser profile, or when the page shows the login wall.

Common situations: CI environments with a brand-new browser profile, clearing cookies manually, ChatGPT logging the session out, or pointing the CLI at a profile never used to log in.

Related errors


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