jackwener/OpenCLI · error · AuthRequiredError

NotebookLM RPC redirected to the login page

Error message

NotebookLM RPC redirected to the login page

What it means

callNotebooklmRpc checks response.finalUrl after following redirects. If the final URL is on the trusted origin but its path is /login or under /login/, NotebookLM bounced the authenticated RPC to the sign-in page, meaning the session credentials are no longer valid. It throws AuthRequiredError so the CLI can prompt for re-authentication instead of failing with a generic HTTP error.

Source

Thrown at clis/notebooklm/rpc.js:246

    const url = NOTEBOOKLM_RPC_PATH +
        `?rpcids=${rpcId}&source-path=${encodeURIComponent(auth.sourcePath)}` +
        (authuser ? `&authuser=${encodeURIComponent(authuser)}` : '') +
        `&hl=${encodeURIComponent(options.hl ?? 'en')}` +
        `&f.sid=${encodeURIComponent(auth.sessionId)}&rt=c`;
    const response = await fetchNotebooklmInPage(page, url, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
        },
        body: requestBody,
    });
    const requestUrl = parseTrustedNotebooklmUrl(response.requestUrl);
    const finalUrl = parseTrustedNotebooklmUrl(response.finalUrl);
    if (!requestUrl || requestUrl.origin !== auth.origin || requestUrl.pathname !== NOTEBOOKLM_RPC_PATH) {
        throw new CommandExecutionError('NotebookLM RPC request resolved outside the active trusted origin');
    }
    if (finalUrl?.origin === auth.origin && (finalUrl.pathname === '/login' || finalUrl.pathname.startsWith('/login/'))) {
        throw new AuthRequiredError(NOTEBOOKLM_DOMAIN, 'NotebookLM RPC redirected to the login page');
    }
    if (!finalUrl || finalUrl.origin !== auth.origin || finalUrl.pathname !== NOTEBOOKLM_RPC_PATH) {
        throw new CommandExecutionError('NotebookLM RPC response redirected outside the active trusted endpoint');
    }
    if (response.status === 401 || response.status === 403) {
        throw new AuthRequiredError(NOTEBOOKLM_DOMAIN, `NotebookLM RPC returned auth error (${response.status})`);
    }
    if (!response.ok) {
        throw new CliError('NOTEBOOKLM_RPC', `NotebookLM RPC request failed with HTTP ${response.status}`, 'Retry from the NotebookLM home page in an already logged-in Chrome session.');
    }
    return {
        auth,
        url: requestUrl.href,
        requestBody,
        response,
        result: extractNotebooklmRpcResult(response.body, rpcId),
    };
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-authenticate: open the attached Chrome profile, sign in to NotebookLM/Google, then retry the command.
  2. Run `opencli notebooklm open <notebook>` to refresh the session and confirm the page shows the logged-in app.
  3. Check the correct Chrome profile is attached (one that actually holds a valid Google session).
  4. Handle AuthRequiredError in calling code to trigger an interactive login flow before retrying RPC calls.

Example fix

// before: retrying RPC blindly on failure
const res = await callNotebooklmRpc(page, auth, method, body);
// after: catch auth errors and re-authenticate first
let res;
try {
  res = await callNotebooklmRpc(page, auth, method, body);
} catch (e) {
  if (e instanceof AuthRequiredError) {
    await reauthenticateNotebooklm(page);
    res = await callNotebooklmRpc(page, auth, method, body);
  } else throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// check session validity before expensive RPC work
const state = await getNotebooklmPageState(page);
if (state.kind === null || /\/login/.test(new URL(page.url()).pathname)) {
  await reauthenticateNotebooklm(page);
}

Try / catch

try {
  const res = await callNotebooklmRpc(page, auth, method, body);
} catch (e) {
  if (e instanceof AuthRequiredError && e.message.includes('redirected to the login page')) {
    await promptGoogleLogin(page); // re-auth in attached Chrome, then retry once
  } else throw e;
}

Prevention

When it happens

Trigger: The Google session cookie expired or was revoked, the RPC returns a 30x redirect to /login, or the attached Chrome profile was logged out (or the user signed out / switched accounts) while the CLI session was open.

Common situations: Long-lived CLI session after cookie expiry; user logged out of Google in the automation Chrome profile; Google invalidated the session server-side (password change, security event); using a profile that was never logged in.

Related errors


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