jackwener/OpenCLI · error · AuthRequiredError

Manus /api/auth/session HTTP ${r.status}

Error message

Manus /api/auth/session HTTP ${r.status}

What it means

The in-page probe fetches /api/auth/session with credentials to verify the Manus identity. When the session cookie exists but the endpoint answers 401 or 403, the probe returns kind:'auth' and verifyManusIdentity throws AuthRequiredError with the status in the detail — meaning the stored credentials are present but rejected by the server.

Source

Thrown at clis/manus/auth.js:35

      const r = await fetch('/api/auth/session', { credentials: 'include', headers: { Accept: 'application/json' } });
      if (r.status === 401 || r.status === 403) {
        return { kind: 'auth', detail: 'Manus /api/auth/session HTTP ' + r.status };
      }
      if (r.status === 503) {
        return { kind: 'http', httpStatus: 503 };
      }
      if (!r.ok) return { kind: 'http', httpStatus: r.status };
      const d = await r.json();
      const u = d?.user || d;
      if (!u || !(u.id || u.userId)) {
        return { kind: 'auth', detail: 'Manus /api/auth/session 200 but no user' };
      }
      return { ok: true, user_id: String(u.id || u.userId), name: String(u.name || u.displayName || '') };
    } catch (e) {
      return { kind: 'exception', detail: String(e && e.message || e) };
    }
  })()`);
  if (probe?.kind === 'auth') throw new AuthRequiredError('manus.im', probe.detail);
  if (probe?.kind === 'http') throw new CommandExecutionError(`HTTP ${probe.httpStatus} from Manus /api/auth/session`);
  if (probe?.kind === 'exception') throw new CommandExecutionError(`Manus whoami failed: ${probe.detail}`);
  if (!probe?.ok) throw new CommandExecutionError(`Unexpected Manus probe: ${JSON.stringify(probe)}`);
  return { user_id: probe.user_id, name: probe.name };
}

registerSiteAuthCommands({
  site: 'manus',
  domain: 'manus.im',
  loginUrl: 'https://manus.im/login',
  columns: ['user_id', 'name'],
  verify: verifyManusIdentity,
  poll: async (page) => {
    if (!await hasManusSessionCookie(page)) {
      throw new AuthRequiredError('manus.im', 'Waiting for Manus session cookies');
    }
    return verifyManusIdentity(page);
  },

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-run opencli manus login to obtain fresh session cookies, replacing the rejected ones.
  2. Clear manus.im cookies for the browser profile and log in again.
  3. Confirm the account is still active and not logged out remotely (Manus web UI).
  4. Check whether Manus changed the /api/auth/session response shape (no user object) and update the CLI if so.
  5. If the CLI can't stay logged in, check for clock skew or proxies stripping/altering cookies.

Example fix

// before: stale cookies auto-fail
opencli manus whoami // AuthRequiredError: Manus /api/auth/session HTTP 401
// after: refresh session programmatically
await page.goto('https://manus.im/login');
// complete login, then retry
opencli manus whoami
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight: check a session cookie exists AND is non-empty
const cookies = await page.getCookies({ url: 'https://manus.im' });
const s = cookies.find(c => c.name === 'auth_session');
if (!s || !s.value) await manusLogin();

Type guard

function isAuthRejected(probe) { return probe?.kind === 'auth'; }

Try / catch

try {
  const identity = await manusWhoami();
} catch (e) {
  if (e.name === 'AuthRequiredError' && /HTTP 40[13]/.test(e.message)) {
    await clearManusCookies(); await manusLogin(); // stale token — re-auth
  } else throw e;
}

Prevention

When it happens

Trigger: Running a manus auth/whoami flow when a stale, expired, or revoked auth_session/manus_token cookie is sent to /api/auth/session and the server responds 401/403; also when a 200 response contains no user object (line 28 returns the same 'auth' kind).

Common situations: Session expired server-side while cookie remains in the profile; Manus invalidated tokens after a security event or password change; account logged out from another device; API schema change leaves the session response without a user object; partially corrupted cookie value.

Related errors


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