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);
const app = new ACApp('your_app_id');
try {
const sessionToken = await app.getSessionToken();
} catch (e) {
if (e.message === ERROR_MSG.getSessionToken.timeout) {
}
}
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) {
}
}
pageURL = app.getAppCenterURL();