yikart/AiToEarn · error · TikTokPlatformException

15070

15070

Error message

{{platform}} platform API request failed

What it means

TikTokService.createHttpClient() installs a response interceptor on the shared Axios instance; every error response (or network failure) from open.tiktokapis.net is rethrown as TikTokPlatformException.fromAxiosError with code ChannelPlatformApiFailed (15070). The code is specialized by endpoint (/oauth/ -> ChannelAccessTokenFailed, /upload/ and /post/publish/ -> ChannelPlatformMediaProcessingFailed) and by any error code present in the TikTok response body.

Source

Thrown at project/aitoearn-backend/apps/aitoearn-server/src/core/channels/platforms/tiktok/tiktok.service.ts:56

    private readonly mediaService: MediaService,
  ) {
    this.http = this.createHttpClient()
  }

  private readonly apiBaseUrl = 'https://open.tiktokapis.com/v2'
  private readonly authUrl = 'https://www.tiktok.com/v2/auth/authorize'

  private createHttpClient(): AxiosInstance {
    const http = axios.create()
    http.interceptors.response.use(
      (response) => {
        if (TikTokPlatformException.hasPlatformError(response)) {
          throw TikTokPlatformException.fromPlatformResponse(response)
        }
        return response
      },
      (error: AxiosError<TikTokPlatformResponseBody>) => {
        throw TikTokPlatformException.fromAxiosError(error)
      },
    )
    return http
  }

  private async apiRequest<T>(
    url: string,
    options: TikTokRequestOptions = {},
    accessToken?: string,
  ): Promise<T> {
    const headers: Record<string, string> = accessToken
      ? {
          ...(options.headers ?? {}),
          'Authorization': `Bearer ${accessToken}`,
          'Content-Type': 'application/json; charset=UTF-8',
        }
      : {
          ...(options.headers ?? {}),

View on GitHub (pinned to d3aa8bea5b)

Solutions

  1. Read exception.cause.platformCode/httpStatus to get TikTok's specific error code and message
  2. For access_token_invalid, use the refresh token to obtain a new access token before retrying
  3. For upload/publish endpoints, confirm the file upload completed and check CATEGORY is ChannelPlatformMediaProcessingFailed
  4. Verify app scopes and audit status (unreviewed apps can only post SELF_ONLY)
  5. If retryable=true, retry with backoff; otherwise fix app config or parameters

Example fix

// before
const res = await this.http.post(url, body) // interceptor throws 15070
// after
try {
  const res = await this.http.post(url, body)
} catch (e) {
  if (e instanceof ChannelPlatformException && e.cause?.platformCode === 'access_token_invalid') {
    await this.refreshAccessToken(account)
    return this.http.post(url, body)
  }
  throw e
}
Defensive patterns

Strategy: try-catch

Validate before calling

if (!account.accessToken || account.tokenExpiresAt <= new Date()) await refreshTikTokToken(account)

Type guard

function isTikTokPlatformException(e: unknown): e is TikTokPlatformException {
  return e instanceof TikTokPlatformException
}

Try / catch

try {
  const res = await this.http.post(url, body)
} catch (e) {
  if (e instanceof TikTokPlatformException) {
    const code = e.cause?.platformCode
    if (code === 'access_token_invalid') return refreshAndRetry()
    if (e.retryable) return retryWithBackoff()
  }
  throw e
}

Prevention

When it happens

Trigger: Any TikTok Open API call through the constructed client fails: non-2xx HTTP response, TikTok body containing error.code (e.g. access_token_invalid, rate_limit_exceeded, invalid_params), OAuth token endpoint failures, or axios network errors (timeout, DNS, connection refused).

Common situations: Expired TikTok access token (tokens last 24h; refresh token 365d); missing tiktok.trial.publish or video.upload scopes for unreviewed apps; client_key/client_secret misconfigured; upload endpoints hit before chunk completion; corporate proxy blocking open.tiktokapis.net.

Related errors


AI-assisted analysis of yikart/AiToEarn@d3aa8bea5b (2026-08-31). Data as JSON: /api/errors/76cec645601550c9. Report an issue: GitHub.