jackwener/OpenCLI · info · AuthRequiredError

creator.douyin.com

Error message

creator.douyin.com

What it means

An AuthRequiredError raised by the douyin auth poll handler when, while polling during interactive login, none of the expected session cookies (sessionid, uid_tt, passport_csrf_token) are present for creator.douyin.com. It signals the login flow that authentication is still pending. The library throws it so polling continues until the user finishes the QR login.

Source

Thrown at clis/douyin/auth.js:35

    throw new CommandExecutionError('Douyin user info response is missing user_info');
  }
  return {
    id: user.uid ?? '',
    username: user.nickname ?? '',
    followers: user.follower_count ?? 0,
  };
}

registerSiteAuthCommands({
  site: 'douyin',
  domain: 'creator.douyin.com',
  loginUrl: 'https://creator.douyin.com/',
  columns: ['id', 'username', 'followers'],
  quickCheck: hasDouyinSessionCookies,
  verify: verifyDouyinIdentity,
  poll: async (page) => {
    if (!await hasDouyinSessionCookies(page)) {
      throw new AuthRequiredError('creator.douyin.com', 'Waiting for Douyin creator session cookies');
    }
    return verifyDouyinIdentity(page);
  },
});

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Complete the QR login in the opened browser window for creator.douyin.com
  2. Verify the browser context allows cookies and is not isolating creator.douyin.com
  3. Check actual cookie names after login and update hasDouyinSessionCookies if Douyin renamed them
  4. Restart the auth flow with a longer timeout if polling expired

Example fix

// before: poll throws immediately before login completes
const res = await poll(page); // AuthRequiredError
// after: wait for login, then poll
await page.waitForFunction(() => document.cookie.includes('sessionid='), { timeout: 120000 });
const res = await poll(page);
Defensive patterns

Strategy: retry

Validate before calling

const cookies = await page.getCookies({ url: 'https://creator.douyin.com' });
const names = new Set(cookies.map(c => c.name));
const loggedIn = names.has('sessionid') || names.has('uid_tt') || names.has('passport_csrf_token');

Type guard

function hasSessionCookies(cookies) {
  const names = new Set(cookies.map(c => c.name));
  return names.has('sessionid') || names.has('uid_tt') || names.has('passport_csrf_token');
}

Try / catch

try {
  const identity = await poll(page);
} catch (e) {
  if (e instanceof AuthRequiredError || /creator\.douyin\.com/.test(e.message)) {
    await waitForLogin(page, { timeout: 120000 }); // keep waiting for QR scan
    return poll(page);
  } throw e;
}

Prevention

When it happens

Trigger: Polling started before the user scanned the QR code or clicked confirm; user opened the login page but logged into a different Douyin property (no creator.douyin.com cookies); cookies blocked in the browser context; user cancelled login.

Common situations: Automated login timeouts when nobody completes the QR scan; headless browser contexts with cookies disabled; cookie policy changes (e.g. cookie name churn) making the check fail even after login.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/cdb3407a2486e2ac. Report an issue: GitHub.