jackwener/OpenCLI · error · AuthRequiredError

Flomo memos requires an active signed-in Flomo browser sessi

Error message

Flomo memos requires an active signed-in Flomo browser session

What it means

readAccessToken in clis/flomo/memos.js:174 evaluates injected JS in the Flomo browser page that reads the 'me' key from localStorage and extracts access_token. If the value is not a non-empty string — no signed-in session, missing/expired localStorage entry, or the page not being on the Flomo domain — it throws AuthRequiredError for the flomoapp.com domain. This command relies on cookie/session-based auth from a real browser session rather than a static API key.

Source

Thrown at clis/flomo/memos.js:174

    throw new CommandExecutionError(`Failed to fetch Flomo memos: ${err instanceof Error ? err.message : String(err)}`);
  }
  if (resp.status === 401 || resp.status === 403) {
    throw new AuthRequiredError(FLOMO_API_DOMAIN, `Flomo API returned HTTP ${resp.status}; please refresh your Flomo login session`);
  }
  if (!resp.ok) {
    throw new CommandExecutionError(`Flomo API returned HTTP ${resp.status}`);
  }
  try {
    return await resp.json();
  } catch (err) {
    throw new CommandExecutionError(`Flomo API returned malformed JSON: ${err instanceof Error ? err.message : String(err)}`);
  }
}

async function readAccessToken(page) {
  const token = unwrapBrowserResult(await page.evaluate(buildGetTokenJs()));
  if (typeof token !== 'string' || !token.trim()) {
    throw new AuthRequiredError(FLOMO_API_DOMAIN, 'Flomo memos requires an active signed-in Flomo browser session');
  }
  return token.trim();
}

const command = cli({
  site: 'flomo',
  name: 'memos',
  access: 'read',
  description: 'List your Flomo memos',
  domain: FLOMO_API_DOMAIN,
  strategy: Strategy.COOKIE,
  browser: true,
  navigateBefore: `https://${FLOMO_APP_DOMAIN}/`,
  args: [
    { name: 'limit', type: 'int', default: 20, help: 'Number of memos to fetch (1-200)' },
    { name: 'since', type: 'int', help: 'Only memos updated after this Unix timestamp in seconds' },
    { name: 'slug', help: 'Pagination cursor from a previous memo page' },
  ],

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Open https://v.flomoapp.com/ in the automation browser and sign in to Flomo manually (complete 2FA/CAPTCHA if prompted), then re-run the command
  2. Verify localStorage.getItem('me') on v.flomoapp.com contains access_token (possibly nested under .data) — log in again if missing
  3. Use a persistent browser profile so the Flomo session survives between runs instead of an ephemeral/headless profile
  4. If recently changed password or revoked sessions on Flomo, log in again to mint a new access_token

Example fix

// before (failing headless run with fresh profile)
// cli command run with an empty browser profile

// after (ensure a persistent, logged-in profile)
// launch the browser with a persistent user-data dir and log in once:
// browser.launch({ userDataDir: '/path/to/persistent-profile' })
// then in the Flomo tab confirm:
// JSON.parse(localStorage.getItem('me')).access_token !== undefined
Defensive patterns

Strategy: validation

Validate before calling

// Run in the automation browser before invoking the command
const token = (() => {
  try {
    const me = JSON.parse(localStorage.getItem('me') || 'null');
    return me?.access_token || me?.data?.access_token || '';
  } catch { return ''; }
})();
if (typeof token !== 'string' || !token.trim()) {
  throw new Error('No active Flomo session — sign in at https://v.flomoapp.com/ first');
}

Type guard

function hasFlomoToken(me) {
  const token = me?.access_token ?? me?.data?.access_token;
  return typeof token === 'string' && token.trim().length > 0;
}

Try / catch

try {
  await runFlomoMemos();
} catch (err) {
  if (err instanceof AuthRequiredError) {
    // open v.flomoapp.com, complete interactive sign-in, then retry once
    await interactiveFlomoLogin();
    await runFlomoMemos();
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Running the flomo memos command when the automation browser has no active Flomo login: never logged in, session expired, localStorage 'me' key cleared or lacking access_token, or the navigation to v.flomoapp.com redirected to a login page.

Common situations: First run of the CLI without completing Flomo login in the managed browser; Flomo session expiring after inactivity or a password change; running headless with a fresh/ephemeral browser profile; clearing browser data or switching profiles.

Related errors


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