jackwener/OpenCLI · error · AuthRequiredError
Instagram login required before posting a reel
Error message
Instagram login required before posting a reel
What it means
ensureComposerOpen runs in-page JavaScript (buildEnsureComposerOpenJs) to open Instagram's new-post/reel composer. When the page reports reason 'auth', the session is not logged in, and the library throws AuthRequiredError for www.instagram.com. Instagram only allows reel posting from an authenticated session, so this is a hard requirement.
Source
Thrown at clis/instagram/reel.js:71
}
function prepareVideoUpload(filePath) {
const baseName = path.basename(filePath);
if (/^[a-zA-Z0-9._-]+$/.test(baseName)) {
return { originalPath: filePath, uploadPath: filePath };
}
const uploadPath = buildSafeTempVideoPath(filePath);
fs.copyFileSync(filePath, uploadPath);
return {
originalPath: filePath,
uploadPath,
cleanupPath: uploadPath,
};
}
async function ensureComposerOpen(page) {
const result = await page.evaluate(buildEnsureComposerOpenJs());
if (!result?.ok) {
if (result?.reason === 'auth') {
throw new AuthRequiredError('www.instagram.com', 'Instagram login required before posting a reel');
}
throw new CommandExecutionError('Failed to open Instagram reel composer');
}
for (let attempt = 0; attempt < 12; attempt += 1) {
const ready = await page.evaluate(`
(() => {
const isVisible = (el) => {
if (!(el instanceof HTMLElement)) return false;
const style = window.getComputedStyle(el);
const rect = el.getBoundingClientRect();
return style.display !== 'none'
&& style.visibility !== 'hidden'
&& rect.width > 0
&& rect.height > 0;
};
const inputs = Array.from(document.querySelectorAll('input[type="file"]'))
.filter((el) => el instanceof HTMLInputElement)
.filter((el) => {View on GitHub (pinned to 49907e53dc)
Solutions
- Log into www.instagram.com in the browser session before running the reel command.
- Use a persistent browser profile that retains the Instagram session cookies.
- Re-authenticate if Instagram expired/invalidated the session (check for login prompts).
- Add a login/health-check step (e.g. gotoInstagramHome and verify logged-in state) prior to posting.
Example fix
// before await runReel(args); // assumes already logged in // after await gotoInstagramHome(page); if (!(await isLoggedIn(page))) await performInstagramLogin(page); await runReel(args);
Defensive patterns
Strategy: try-catch
Validate before calling
await gotoInstagramHome(page);
const loggedIn = await page.evaluate("() => !!document.querySelector('svg[aria-label], nav a[href=\"/\"]') && !location.pathname.startsWith('/accounts/login')");
if (!loggedIn) throw new Error('Instagram session not logged in; authenticate first'); Try / catch
try { await reel(args); } catch (e) { if (e.name === 'AuthRequiredError' || /login required/i.test(e.message)) { await performInstagramLogin(page); return reel(args); } throw e; } Prevention
- Use a persistent browser profile that keeps Instagram cookies
- Verify logged-in state before any posting command
- Re-login proactively when sessions expire
- Avoid clearing cookies between automation runs
When it happens
Trigger: Evaluating the composer-open script against a page where the user is logged out — no session cookies, expired Instagram session, incognito profile without login, or the page redirected to the login screen.
Common situations: Fresh browser profile never logged in, Instagram invalidated the session (password change, security checkpoint), cookies cleared between runs, or automation environment where the login step was skipped.
Related errors
- Browser session required for bilibili subtitle
- Browser session required for bilibili summary
- Browser session required for bilibili unfollow
- Browser session required for bilibili video
- ChatGPT requires a logged-in browser session.
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/10a533002bed702d.
Report an issue: GitHub.