jackwener/OpenCLI · error · AuthRequiredError
WeChat Channels sessionid cookie missing
Error message
WeChat Channels sessionid cookie missing
What it means
verifyWechatChannelsIdentity first checks the browser profile for a non-empty `sessionid` cookie on channels.weixin.qq.com (hasWechatChannelsSessionCookie). Without it the WeChat Channels platform calls cannot authenticate, so an AuthRequiredError is thrown directing the user to log in via the site's auth flow.
Source
Thrown at clis/wechat-channels/auth.js:11
import { AuthRequiredError, CommandExecutionError } from '@jackwener/opencli/errors';
import { registerSiteAuthCommands } from '../_shared/site-auth.js';
async function hasWechatChannelsSessionCookie(page) {
const cookies = await page.getCookies({ url: 'https://channels.weixin.qq.com' });
return cookies.some(c => c.name === 'sessionid' && c.value);
}
async function verifyWechatChannelsIdentity(page) {
if (!await hasWechatChannelsSessionCookie(page)) {
throw new AuthRequiredError('channels.weixin.qq.com', 'WeChat Channels sessionid cookie missing');
}
await page.goto('https://channels.weixin.qq.com/platform');
await page.wait(2);
const probe = await page.evaluate(`(async () => {
try {
if (/login\\.html/.test(location.href)) {
return { kind: 'auth', detail: 'WeChat Channels platform redirected to login.html' };
}
const r = await fetch('/cgi-bin/mmfinderassistant-bin/auth/auth_data', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: '{}',
});
if (!r.ok) return { kind: 'http', httpStatus: r.status };
const d = await r.json();
if (!d || d.base_resp?.ret !== 0) {
return { kind: 'auth', detail: 'WeChat Channels auth_data base_resp.ret=' + String(d?.base_resp?.ret) };View on GitHub (pinned to 49907e53dc)
Solutions
- Run the site's login flow: open https://channels.weixin.qq.com/login.html?from=assistant and scan the QR code with the WeChat app.
- Re-check cookies after login: a non-empty sessionid cookie must exist for channels.weixin.qq.com.
- If using a persistent profile, point the tool at the profile where you actually logged in.
- If the session expired repeatedly, log in again shortly before running commands.
- Verify system clock is sane — skewed clocks can cause servers to invalidate sessions.
Example fix
// before (no login) wechat-channels list // after wechat-channels login # scan QR in WeChat app wechat-channels list
Defensive patterns
Strategy: validation
Validate before calling
// Pre-flight: verify session cookie before invoking any wechat-channels command
const cookies = await page.getCookies({ url: 'https://channels.weixin.qq.com' });
if (!cookies.some(c => c.name === 'sessionid' && c.value)) {
throw new Error('Not logged in — run wechat-channels login first');
} Type guard
function hasSession(cookies) { return Array.isArray(cookies) && cookies.some(c => c.name === 'sessionid' && !!c.value); } Try / catch
try {
await wechatChannelsCommand(args);
} catch (e) {
if (e instanceof AuthRequiredError || /sessionid cookie missing/.test(e.message)) {
await runLoginFlow(); // open login.html, await QR scan
await wechatChannelsCommand(args);
} else throw e;
} Prevention
- Run the login flow before scripted operations; keep the profile persistent
- Re-login proactively when sessions are old
- Check the cookie exists for the exact domain channels.weixin.qq.com
- Don't share/incognito profiles for automation sessions
When it happens
Trigger: Running any wechat-channels command before ever logging in; the saved browser profile was cleared or is fresh; the session expired and WeChat deleted the sessionid cookie; cookies exist for a different domain (e.g. qq.com main site) but not channels.weixin.qq.com.
Common situations: First-time setup; container/incognito profile without stored cookies; WeChat revoked the session server-side; switching machines or browser profiles.
Related errors
- Chaoxing session cookies missing
- Claude sessionKey cookie missing
- Claude session incomplete — ajs_user_id cookie missing
- Google session cookies are missing
- LinkedIn JSESSIONID cookie not found. Please sign in to Link
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/1ec27c9411886724.
Report an issue: GitHub.