{"record":{"id":"9c6b21995a0f76cc","repo":"gitroomhq/postiz-app","slug":"handleerror-value-information-message-c","errorCode":null,"errorMessage":"${handleError?.value || information?.message || 'Could not load the TikTok business account'}","messagePattern":"\\$\\{handleError\\?\\.value \\|\\| information\\?\\.message \\|\\| 'Could not load the TikTok business account'\\}","errorType":"exception","errorClass":"BadBody","httpStatus":null,"severity":"error","filePath":"libraries/nestjs-libraries/src/integrations/social/tiktok.business.provider.ts","lineNumber":280,"sourceCode":"        )}&fields=${encodeURIComponent(\n          JSON.stringify(['username', 'display_name', 'profile_image'])\n        )}`,\n        {\n          method: 'GET',\n          headers: {\n            'Access-Token': accessToken,\n          },\n        }\n      )\n    ).json();\n\n    // A non-zero code arrives as HTTP 200: without this check the auth flow\n    // would \"succeed\" with an undefined name/picture/profile and create a\n    // broken channel.\n    if (information?.code !== 0) {\n      const asString = JSON.stringify(information);\n      const handleError = this.handleErrors(asString);\n      throw new BadBody(\n        'tiktok-business',\n        asString,\n        Buffer.from('{}'),\n        handleError?.value ||\n          information?.message ||\n          'Could not load the TikTok business account'\n      );\n    }\n\n    return {\n      display_name: information.data?.display_name,\n      profile_image: information.data?.profile_image,\n      username: information.data?.username,\n    };\n  }\n\n  async refreshToken(refreshToken: string): Promise<AuthTokenDetails> {\n    const response = await (","sourceCodeStart":262,"sourceCodeEnd":298,"githubUrl":"https://github.com/gitroomhq/postiz-app/blob/0f1647f7491a217d43eb5ae7a480484bdf0aff3e/libraries/nestjs-libraries/src/integrations/social/tiktok.business.provider.ts#L262-L298","documentation":"fetchUserInformation calls TikTok's Business API user endpoint during OAuth. TikTok returns errors as HTTP 200 with a non-zero code, so the provider checks information.code !== 0 and throws BadBody with TikTok's message instead of silently creating a channel with undefined name/picture.","triggerScenarios":"The /user/info/ call returns code != 0: invalid/expired access_token, missing scopes (user.info.basic), or sandbox app not approved for the queried advertiser.","commonSituations":"App missing the user info scope, token exchanged against the wrong app_id/secret pair, or the TikTok account has no business/advertiser profile attached.","solutions":["Check the logged JSON body - code+message name the exact API error","Verify the TikTok app has user.info.basic scope and the account is a Business account","Re-run the OAuth flow to get a fresh token","Confirm app_id/secret pair matches the one used for auth_code exchange"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// after token exchange, sanity-check the user fetch before saving the channel\nconst info = await provider.fetchUserInformation(token);\nif (info?.code !== 0 || !info?.data) throw new Error('TikTok user info incomplete; aborting channel creation');","typeGuard":"const isTikTokOk = (r: any): r is { code: 0; data: Record<string, any> } => r?.code === 0 && !!r?.data;","tryCatchPattern":"try { await connectTikTokBusiness(code); } catch (e) { if (/TikTok business account/.test(e.message)) showReconnectFlow(); else throw e; }","preventionTips":["Request user.info.basic scope in the TikTok app","Validate the code envelope before persisting the channel","Test with an account that has a business/advertiser profile"],"tags":["tiktok","oauth","http-200-error-envelope","business-api"],"backgroundTag":"api-error-envelope-http-200","analyzedSha":"0f1647f7491a217d43eb5ae7a480484bdf0aff3e","analyzedAt":"2026-08-27T12:09:55.020Z","schemaVersion":2},"datasetVersion":"2026-08-27T13:17:12.746Z"}