jackwener/OpenCLI · error · AuthRequiredError
获取抖音上传授权失败: ${message}
Error message
获取抖音上传授权失败: ${message} What it means
getUploadAuthV5Credentials fetches temporary VOD upload credentials via an in-page fetch on creator.douyin.com. When the endpoint returns status_code 401/403, or the message matches auth/login/captcha-related keywords, the code rethrows as AuthRequiredError so callers can prompt a re-login. This means the browser session cookies for creator.douyin.com are no longer valid or are being challenged.
Source
Thrown at clis/douyin/_shared/vod-upload.js:105
if (typeof condition === 'string') {
const parsedCondition = JSON.parse(condition);
return parsedCondition.UserId || '';
}
} catch {
return '';
}
return '';
}
export async function getUploadAuthV5Credentials(page) {
const result = unwrapEvaluateResult(await page.evaluate(`fetch(${JSON.stringify(AUTH_V5_URL)}, { credentials: 'include' }).then(r => r.json())`));
if (!result || Array.isArray(result) || typeof result !== 'object') {
throw new CommandExecutionError(`获取抖音上传授权失败: ${JSON.stringify(result)}`);
}
if (result.status_code !== 0) {
const message = result.status_msg ?? result.message ?? 'unknown error';
if (result.status_code === 401 || result.status_code === 403 || /login|cookie|auth|captcha|verify|forbidden|permission|登录|登陆|权限|验证|验证码/i.test(String(message))) {
throw new AuthRequiredError('creator.douyin.com', `获取抖音上传授权失败: ${message}`);
}
throw new CommandExecutionError(`获取抖音上传授权失败: ${JSON.stringify(result)}`);
}
if (!result.auth) {
throw new CommandExecutionError(`获取抖音上传授权失败: ${JSON.stringify(result)}`);
}
let auth;
try {
auth = JSON.parse(result.auth);
} catch (error) {
throw new CommandExecutionError(`解析抖音上传授权失败: ${error instanceof Error ? error.message : String(error)}`);
}
if (!auth.AccessKeyID || !auth.SecretAccessKey || !auth.SessionToken) {
throw new CommandExecutionError('抖音上传授权缺少 AccessKeyID/SecretAccessKey/SessionToken');
}
return {
access_key_id: auth.AccessKeyID,
secret_access_key: auth.SecretAccessKey,View on GitHub (pinned to 49907e53dc)
Solutions
- Log in (or re-log in) to creator.douyin.com in the same browser/profile the automation drives, then retry.
- If a CAPTCHA/verification challenge was raised, complete it manually in the browser before retrying.
- Confirm the account actually has video-upload permission for the VOD space.
- Clear stale cookies or use a fresh logged-in profile if repeated 403s persist.
- Check whether requests come from a risky IP (VPN/proxy) and switch networks.
Example fix
// before
const creds = await getUploadAuthV5Credentials(page);
// after
try {
const creds = await getUploadAuthV5Credentials(page);
} catch (e) {
if (e instanceof AuthRequiredError) {
await promptUserLogin('creator.douyin.com'); // re-login then retry
return getUploadAuthV5Credentials(page);
}
throw e;
} Defensive patterns
Strategy: try-catch
Validate before calling
// pre-check login state in page context before fetching auth
const loggedIn = await page.evaluate(() => document.cookie.includes('sessionid'));
if (!loggedIn) throw new Error('请先登录 creator.douyin.com 再上传'); Type guard
function isAuthRequiredError(e) {
return e instanceof Error && e.name === 'AuthRequiredError';
} Try / catch
try {
const creds = await getUploadAuthV5Credentials(page);
} catch (e) {
if (isAuthRequiredError(e)) {
await promptLogin('creator.douyin.com');
return getUploadAuthV5Credentials(page);
}
throw e;
} Prevention
- Keep the automated browser profile logged in and refresh the session before long upload batches.
- Detect CAPTCHA/verification pages proactively before starting uploads.
- Run from a stable residential IP; avoid datacenter proxies that trigger risk control.
- Confirm account upload permissions before automating.
When it happens
Trigger: The AUTH_V5_URL response has status_code 401 or 403, or its status_msg/message matches /login|cookie|auth|captcha|verify|forbidden|permission|登录|登陆|权限|验证|验证码/i.
Common situations: Session cookies expired after hours/days; the account was logged out remotely; Douyin served a CAPTCHA or risk-control verification; the account lacks upload permission; IP risk control triggers a verify challenge.
Related errors
- ${probe.detail}
- Douyin API auth/permission error ${code} at ${method} ${url}
- 用户信息获取失败,请确认已登录 creator.douyin.com
- weibo.com
- Please log in to the WeChat Official Account platform and re
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/0b479156f003fda6.
Report an issue: GitHub.