🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

@tiktok-service/app-center-connect

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tiktok-service/app-center-connect

TikTok App Center App Connect Library

latest
npmnpm
Version
0.3.0
Version published
Weekly downloads
2.5K
26.23%
Maintainers
1
Weekly downloads
 
Created
Source

TikTok App Connect Library

Introduction

TikTok App Connect library provides a simple way for the app center apps to communicate with TikTok app center page. It currently supports functions including:

  • Get session token (getSessionToken)
  • Redirect users to API authorization page (redirectToAuth)
  • Allow users to request redirection to any pages (requestRedirectionTo)

How to install

npm i @tiktok-service/app-center-connect

How to Use

Below is the sample code for how to use the methods provided in the package.

import ACApp, { ERROR_MSG } from '@tiktok-service/app-center-connect';

console.log(ERROR_MSG);
// The list of possible error messages for each function call was exported as `ERROR_MSG`
/*
{
    getSessionToken: {
        failed: "failed to get session token. please try again later",
        timeout: "request timeout"
    },
    redirectToAuth: {
        unsupported:
            "Unsupported auth type. Please select from: MAPI, TTAAPI and CMAPI"
    },
}
*/

const app = new ACApp('your_app_id');

// <!-- Get Session Token -->
try {
  const sessionToken = await app.getSessionToken();
} catch (e) {
  if (e.message === ERROR_MSG.getSessionToken.timeout) {
    // handle timeout error
  }
  // <!-- ... -->
}

// <!-- Redirect to TikTok Accounts API/Creator Marketplace API Auth Page -->
// <!-- Supported auth type: MAPI - Marketing API -->
// <!-- Supported auth type: TTAAPI - TikTok Accounts API -->
// <!-- Supported auth type: CMAPI - Creator Marketplace API -->
app.redirectToAuth('TTAAPI' / 'CMAPI');

try {
  const isRedirectionSuccessful = await app.requestRedirectionTo(
    'https://example.com/'
  );
  console.log(isRedirectionSuccessful);
} catch (e) {
  if (e.message === ERROR_MSG.requestRedirectionTo.notAllowed) {
    // handle URL not allowed error
  }
}

// <!-- Get App Center Page URL -->
pageURL = app.getAppCenterURL();

FAQs

Package last updated on 04 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts