{"record":{"id":"942116d8b9f48c6c","repo":"jackwener/OpenCLI","slug":"www-youtube-com-942116","errorCode":null,"errorMessage":"www.youtube.com","messagePattern":"www\\.youtube\\.com","errorType":"exception","errorClass":"AuthRequiredError","httpStatus":null,"severity":"critical","filePath":"clis/youtube/unlike.js","lineNumber":60,"sourceCode":"            'Content-Type': 'application/json',\n            'Authorization': authHash,\n            'X-Origin': 'https://www.youtube.com',\n          },\n          body: JSON.stringify({ context, target: { videoId: ${JSON.stringify(videoId)} } }),\n        });\n\n        if (resp.status === 401 || resp.status === 403) return { error: 'auth', message: 'Not logged in' };\n        if (!resp.ok) {\n          const body = await resp.json().catch(() => ({}));\n          const errStatus = body?.error?.status || '';\n          if (errStatus === 'UNAUTHENTICATED') return { error: 'auth', message: 'Not logged in' };\n          return { error: 'http', message: 'HTTP ' + resp.status + (errStatus ? ' ' + errStatus : '') };\n        }\n        return { ok: true };\n      })()\n    `);\n        if (result?.error === 'auth') {\n            throw new AuthRequiredError('www.youtube.com');\n        }\n        if (result?.error) {\n            throw new CommandExecutionError(result.message || 'Failed to remove like');\n        }\n        return [{ status: 'success', message: 'Unliked: ' + videoId }];\n    },\n});\n","sourceCodeStart":42,"sourceCodeEnd":68,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/youtube/unlike.js#L42-L68","documentation":"AuthRequiredError re-thrown after the in-page YouTube API call reports error === 'auth'. The page-side evaluate detected that YouTube's endpoint rejected the request as unauthenticated (typically a 401/login-required response from the like/unlike internal API), so the library converts it into AuthRequiredError for www.youtube.com. Unlike 5050, the SAPISID cookie existed but the session was still deemed unauthenticated.","triggerScenarios":"The page.evaluate payload returns { error: 'auth' } — e.g. YouTube's /youtubei/v1/like/removelike endpoint responds 401 or an auth-required status even though a SAPISID cookie was present.","commonSituations":"Stale/expired session cookies that still contain SAPISID but fail server-side validation; YouTube session revoked (password change, security event); missing or mismatched SAPISIDHASH authorization header due to ytcfg changes; account requires re-verification.","solutions":["Re-login to www.youtube.com in the automation browser profile to refresh the Google session, then retry.","Clear and re-establish YouTube cookies (fresh login) so SAPISID matches a valid session.","Check the in-page request includes a correct SAPISIDHASH Authorization header built from the current SAPISID and origin.","Update the library if YouTube changed the internal like/unlike API auth requirements."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const sapisid = await readYoutubeSapisid(page);\nif (!sapisid) throw new Error('YouTube session invalid — re-login required');","typeGuard":null,"tryCatchPattern":"try {\n  await unlike({ url });\n} catch (e) {\n  if (e.name === 'AuthRequiredError') {\n    await refreshYoutubeSession(page);\n    return unlike({ url });\n  }\n  throw e;\n}","preventionTips":["Treat a SAPISID cookie as necessary but not sufficient — sessions can be server-side revoked; detect 401/auth errors and re-login.","Refresh Google sessions periodically in long-lived automation profiles.","Keep the SAPISIDHASH header construction in sync with the current SAPISID and origin.","Watch for account security events (password changes) that invalidate cookies."],"tags":["auth","youtube","session-expired","api-401"],"backgroundTag":"auth-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}