Usage
Updated: 2025-02-28 14:41:01
This document primarily describes the API usage of the verification module.
1. Verify Viewer Login Token
After obtaining the viewer login token, you can verify it using verifyViewerLoginToken. Once verification is successful, you can proceed to install the core instance.
For details on obtaining the login token, refer to the documentation: Click here
Note: Verification will bypass viewing condition authorization.
API Method: verifyViewerLoginToken(loginToken: string): Promise<VerifyLoginTokenResult>
Parameter Description:
- loginToken: Viewer login token, type
string, required
Return Value Description: Verification result, type Promise<VerifyLoginTokenResult>
Example:
import { createWatchCore } from '@polyv/live-watch-sdk';
// 获取登录令牌
function getLoginToken() {
// TODO:请求 api 接口获取登录令牌
}
async function example() {
// 创建核心实例
const watchCore = createWatchCore({ channelId: '' });
// 步骤1:获取登录令牌
const loginToken = await getLoginToken();
// 步骤2:验证登录令牌
await watchCore.verify.verifyViewerLoginToken(loginToken);
// 步骤3:安装核心实例
await watchCore.setup();
// 此时观看条件授权状态为已授权
console.log(watchCore.auth.isAuthorized()); // true
}
