jackwener/OpenCLI · error · AuthRequiredError
auth
Error message
auth
What it means
After the cookie check, the in-page probe is evaluated on youtube.com. If the probe reports kind === 'auth', the page itself signaled the user is not authenticated (e.g. redirected to a sign-in page), so AuthRequiredError('www.youtube.com', probe.detail) is thrown with the page-reported detail.
Source
Thrown at clis/youtube/auth.js:36
const cfg = (typeof window !== 'undefined' && window.ytcfg && typeof window.ytcfg.get === 'function') ? window.ytcfg : null;
// ytcfg LOGGED_IN is the reliable signed-in signal; the avatar button is a fallback.
const loggedIn = !!(cfg && cfg.get('LOGGED_IN') === true) || !!document.querySelector('#avatar-btn');
if (!loggedIn) {
return { kind: 'auth', detail: 'YouTube ytcfg LOGGED_IN not true and no avatar — not signed in' };
}
// Name is best-effort: YouTube's masthead avatar exposes a generic
// "Account menu" aria-label, so the channel name is often unavailable
// without opening the menu. Surface it when present, else leave empty.
let name = '';
try { const ctx = cfg && cfg.get('INNERTUBE_CONTEXT'); name = (ctx && ctx.user && ctx.user.identityName) || ''; } catch {}
if (!name) {
const aria = (document.querySelector('#avatar-btn')?.getAttribute('aria-label') || '').trim();
if (aria && !/^account menu$/i.test(aria)) name = aria;
}
return { ok: true, name: String(name || '') };
})()
`);
if (probe?.kind === 'auth') throw new AuthRequiredError('www.youtube.com', probe.detail);
if (!probe?.ok) throw new CommandExecutionError(`Unexpected YouTube probe: ${JSON.stringify(probe)}`);
return { name: probe.name };
}
registerSiteAuthCommands({
site: 'youtube',
domain: 'www.youtube.com',
loginUrl: 'https://accounts.google.com/ServiceLogin?service=youtube&continue=https%3A%2F%2Fwww.youtube.com%2F',
columns: ['name'],
quickCheck: hasGoogleSessionCookie,
verify: verifyYoutubeIdentity,
poll: async (page) => {
if (!await hasGoogleSessionCookie(page)) {
throw new AuthRequiredError('www.youtube.com', 'Waiting for Google session cookies');
}
return verifyYoutubeIdentity(page);
},
});View on GitHub (pinned to 49907e53dc)
Solutions
- Re-run the login flow to refresh Google/YouTube session cookies
- Complete any Google security or consent challenges in the automated browser once manually
- Check probe.detail in the error for the page-reported reason
- Wait and retry if YouTube is showing a transient interstitial
Defensive patterns
Strategy: try-catch
Validate before calling
const cookies = await getCookies('https://www.youtube.com');
if (!new Set(cookies.map(c => c.name)).has('SAPISID')) {
await runLoginFlow('youtube');
} Try / catch
try {
await cli.youtube.whoami();
} catch (e) {
if (e.name === 'AuthRequiredError') {
console.error('YouTube session rejected:', e.message);
await cli.login('youtube'); // refresh cookies / clear challenges
} else throw e;
} Prevention
- Refresh cookies proactively; Google sessions expire
- Complete security/consent challenges manually once in the automated browser
- Keep the logged-in Google account active for YouTube
- Read the wrapped detail for the page-reported reason
When it happens
Trigger: Google cookies exist but YouTube still treats the session as signed out — expired/invalid cookies, YouTube rejecting the session, anti-bot interstitials, or the page redirected to a consent/login screen before probing.
Common situations: Stale SID/SAPISID cookies that no longer authenticate; Google security challenges (suspicious activity); consent/ToS page blocking the session; cookies from a different Google account without YouTube access.
Related errors
- www.youtube.com
- www.youtube.com
- www.youtube.com
- Not logged in (SAPISID cookie missing)
- Not logged in (SAPISID cookie missing)
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/5d222e7fb32dff1a.
Report an issue: GitHub.