jackwener/OpenCLI · error · AuthRequiredError
Log into Midjourney in Chrome, then retry.
Error message
Log into Midjourney in Chrome, then retry.
What it means
midjourneyJson wraps all HTTP errors; when the error message matches /HTTP\s+(401|403)|unauthorized|login|sign in/i it raises AuthRequiredError instead of a generic CommandExecutionError. It signals the Midjourney cookies in Chrome are missing or expired and the request was not authenticated. The user must log in interactively.
Source
Thrown at clis/midjourney/utils.js:282
if (!raw) throw new ArgumentError('--output cannot be empty');
const expanded = raw === '~' ? os.homedir() : raw.startsWith('~/') ? path.join(os.homedir(), raw.slice(2)) : raw;
return path.resolve(expanded);
}
function errorMessage(error) {
return error instanceof Error ? error.message : String(error);
}
async function midjourneyJson(page, endpoint, options = {}) {
try {
return await page.fetchJson(endpoint, {
...options,
headers: { ...CSRF_HEADERS, ...(options.headers || {}) },
});
} catch (error) {
const message = errorMessage(error);
if (/HTTP\s+(401|403)|unauthori[sz]ed|login|sign in/i.test(message)) {
throw new AuthRequiredError(MIDJOURNEY_DOMAIN, 'Log into Midjourney in Chrome, then retry.');
}
throw new CommandExecutionError(`Midjourney API request failed: ${message}`);
}
}
export async function getMidjourneyAccount(page) {
const account = await midjourneyJson(page, '/api/subscriptions-check');
if (!account || typeof account !== 'object' || Array.isArray(account)) {
throw new CommandExecutionError('Midjourney subscription endpoint returned a malformed payload');
}
if (!account.user_id) {
throw new AuthRequiredError(MIDJOURNEY_DOMAIN, 'Log into Midjourney in Chrome, then retry.');
}
return account;
}
export function assertGenerationEntitlement(account) {
if (account.status !== 'active' || !account.plan?.type) {View on GitHub (pinned to 49907e53dc)
Solutions
- Open Chrome, log into midjourney.com, verify the dashboard loads, then rerun the command.
- Confirm the CLI is pointed at the same Chrome profile that holds the session.
- Clear stale cookies for midjourney.com and log in again if a corrupted session persists.
- Disable conflicting VPN/proxy that may invalidate the session, then re-authenticate.
Example fix
// before
await midjourneyJson(page, '/api/subscriptions-check'); // throws AuthRequiredError
// after
const account = await getMidjourneyAccount(page).catch(async (e) => {
if (e instanceof AuthRequiredError) { await interactiveLogin(page); return getMidjourneyAccount(page); }
throw e;
}); Defensive patterns
Strategy: try-catch
Type guard
function isAuthRequiredError(err) {
return err != null && typeof err === 'object' &&
(/HTTP\s+(401|403)|unauthori[sz]ed|login|sign in/i.test(String(err.message)) || err.constructor?.name === 'AuthRequiredError');
} Try / catch
try {
const account = await midjourneyJson(page, '/api/subscriptions-check');
} catch (err) {
if (isAuthRequiredError(err)) {
console.error('Session expired. Open Chrome, log into midjourney.com, then retry.');
process.exitCode = 2; // distinct code for auth failures
} else throw err;
} Prevention
- Re-login to midjourney.com periodically; sessions expire
- Pin the CLI to a dedicated Chrome profile that stays logged in
- Detect AuthRequiredError and surface an actionable message instead of retrying
- Avoid IP/VPN churn that can invalidate sessions
When it happens
Trigger: Any midjourneyJson call (account, payload, history) whose underlying request fails with HTTP 401/403 or an error message mentioning login/sign-in/unauthorized.
Common situations: Midjourney session cookie expired after weeks of inactivity, using a fresh Chrome profile that never logged in, VPN/IP change invalidating the session, or Midjourney rotating CSRF/session requirements.
Related errors
- bbs.hupu.com
- HTTP ${response.status} - make sure you are logged in to Ins
- LinkedIn Sales Navigator API auth failed (HTTP ' + (result.s
- linux.do requires an active signed-in browser session
- Manus /api/auth/session HTTP ${r.status}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/4d0ba1c448a4bd96.
Report an issue: GitHub.