jackwener/OpenCLI · error · AuthRequiredError

Douyin API auth/permission error ${code} at ${method} ${url}

Error message

Douyin API auth/permission error ${code} at ${method} ${url}: ${msg}

What it means

When the Douyin API responds with a non-zero status_code that looks like an auth/permission problem (per isAuthLikeError), browserFetch throws AuthRequiredError for creator.douyin.com. This signals the session's credentials are missing, expired, or lack permission for the endpoint.

Source

Thrown at clis/douyin/_shared/browser-fetch.js:67

    }
    catch (error) {
        throw new CommandExecutionError(`Douyin API request failed (${method} ${url}): ${error instanceof Error ? error.message : String(error)}`);
    }
    if (result == null) {
        throw new CommandExecutionError(
            `Empty response from Douyin API (${method} ${url})`,
            'The endpoint may have been retired or may now require signed parameters.',
        );
    }
    if (Array.isArray(result) || typeof result !== 'object') {
        throw new CommandExecutionError(`Malformed response from Douyin API (${method} ${url})`);
    }
    if (result && typeof result === 'object' && 'status_code' in result) {
        const code = result.status_code;
        if (code !== 0) {
            const msg = result.status_msg ?? result.message ?? 'unknown error';
            if (isAuthLikeError(code, msg)) {
                throw new AuthRequiredError('creator.douyin.com', `Douyin API auth/permission error ${code} at ${method} ${url}: ${msg}`);
            }
            throw new CommandExecutionError(`Douyin API error ${code} at ${method} ${url}: ${msg}`);
        }
    }
    return result;
}

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-login to creator.douyin.com in the browser used by the tool and refresh the session/cookies.
  2. Confirm the logged-in account has creator publishing permissions.
  3. Retry after completing any captcha/risk-control challenge Douyin presented.
  4. If persistent, clear stale cookie state and rebuild the authenticated session from scratch.

Example fix

// before: retrying endlessly on auth error
while (true) { await browserFetch(page, api); }
// after: catch AuthRequiredError and force re-login
import { AuthRequiredError } from './_shared/errors.js';
try {
  const data = await browserFetch(page, api);
} catch (e) {
  if (e instanceof AuthRequiredError) {
    await reloginCreatorDouyin();
    return browserFetch(page, api);
  }
  throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

null

Type guard

null

Try / catch

import { AuthRequiredError } from './_shared/errors.js';
try {
  const data = await browserFetch(page, api);
} catch (e) {
  if (e instanceof AuthRequiredError) {
    await relogin('creator.douyin.com');
    return browserFetch(page, api); // single retry after re-auth
  }
  throw e;
}

Prevention

When it happens

Trigger: result.status_code !== 0 and isAuthLikeError(code, msg) is true — e.g. status codes/messages indicating not-logged-in, session expired, or insufficient permissions on creator.douyin.com APIs.

Common situations: Browser cookies expired overnight; running the CLI on a machine whose stored session was revoked; using an account without creator permissions; Douyin invalidating sessions after risk-control checks.

Related errors


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