yikart/AiToEarn · error · AppException
ChannelPlatformApiFailed
ChannelPlatformApiFailed
Error message
ChannelPlatformApiFailed
What it means
ChannelPlatformApiFailed (field share_id) is thrown by DouyinService.getShareid when the /share-id/ call to the Douyin Open Platform succeeds at HTTP level but response.data.data.share_id is missing or empty. It signals that the platform responded unexpectedly rather than a transport error, and the service carries reasonCode 'missing_platform_field' to pinpoint which field was absent.
Source
Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/douyin/douyin.service.ts:244
openId: user.open_id,
unionId: user.union_id,
nickname: user.nickname,
avatar: user.avatar,
city: user.city,
province: user.province,
country: user.country,
eAccountRole: user.e_account_role,
}
}
async getShareid(): Promise<string> {
const response = await this.requestShareId<DouyinShareIdEnvelope>({
need_callback: true,
default_hashtag: 'hashtag',
})
const shareId = response.data.data?.share_id
if (!shareId) {
throw new AppException(ResponseCode.ChannelPlatformApiFailed, { platform: AccountType.Douyin, field: 'share_id', reasonCode: 'missing_platform_field' })
}
return shareId
}
async getSharePublishResult(shareId: string): Promise<DouyinSharePublishResult> {
const response = await this.requestShareId<DouyinSharePublishResultEnvelope>({
share_id: shareId,
})
const data = response.data.data ?? {}
return {
shareId: data.share_id ?? shareId,
itemId: data.item_id,
videoId: data.video_id,
shareUrl: data.share_url,
raw: data,
}View on GitHub (pinned to d3aa8bea5b)
Solutions
- Inspect the raw response body from POST https://open.douyin.com/share-id/ to see the platform error code/message returned in the envelope.
- Verify DOUYIN client_key/client_secret config matches an approved Douyin Open Platform app with share permissions.
- Confirm the client token used is valid (this path refreshes stale tokens, but a hard credential failure still yields an empty share_id).
- Retry after confirming Douyin platform status; if quota-limited, reduce share-id request rate or request a quota increase.
Example fix
// before
// response: { data: { data: null, description: 'client_key invalid' } } -> throws
const shareId = await douyinService.getShareid()
// after
// fix config so the envelope contains data.share_id
// DOUYIN_CLIENT_KEY=<approved key>; DOUYIN_CLIENT_SECRET=<matching secret>
const shareId = await douyinService.getShareid() // returns e.g. 'share_abc123' Defensive patterns
Strategy: retry
Type guard
const hasShareId = (r: unknown): r is { data: { data: { share_id: string } } } =>
!!r && typeof r === 'object' &&
!!(r as any).data?.data?.share_id Try / catch
try {
const shareId = await douyinService.getShareid()
} catch (err) {
if (err instanceof AppException && err.code === ResponseCode.ChannelPlatformApiFailed && err.data?.field === 'share_id') {
// check Douyin platform error envelope / credentials, then retry with backoff
} else throw err
} Prevention
- Keep Douyin Open Platform clientId/clientSecret config verified in every environment
- Monitor platform error codes returned in the /share-id/ envelope, not just HTTP status
- Apply backoff between share-id requests to avoid quota limits
- Subscribe to Douyin Open Platform status/announcements for API changes
When it happens
Trigger: Any call path that requests a Douyin share id (offline-QR publish handoff) where the /share-id/ envelope returns data=null, an error payload (e.g. client_token invalid, app quota exceeded, wrong client_key), or a data object without share_id.
Common situations: Douyin Open Platform app credentials (clientId/clientSecret) misconfigured; app not approved for share-id API; Douyin returning an error envelope that the HTTP layer does not reject; platform-side incidents; request signature/token mismatch after credential rotation.
Related errors
- ChannelPlatformMediaProcessingFailed
- ChannelPlatformResponseInvalid
- 获取三方平台数据失败
- ResponseCode.ChannelAccountCreateRequiredFieldMissing
- ChannelAuthRefreshTokenMissing
AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31).
Data as JSON: /api/errors/c3f730b95a9494ad.
Report an issue: GitHub.