Web Domain: The domain information entered during project creation. The license can be used only under this domain.
Note:
Be sure to use the license key and token that match the developed domain, otherwise authentication will fail, and the SDK cannot be properly initialized.
Preparing signing information
In addition to the license key that is needed to authorize the SDK, you also need to use the token to sign the APIs called in the SDK.
Signature algorithm authentication process
Token: Your unique ID, which is used to sign SDK APIs.
App ID: The APPID displayed in the Beauty AR console.
Timestamp: The current time accurate to the second (10 digits).
Signature: The signature used for signing, which expires after five minutes.
Deploying a signature service
Because the signature expires after a given time, and to prevent the token from being leaked, you need to deploy a signature generation service.
Note:
If the token is leaked, your identity will be stolen, which will lead to your resources also being leaked.
If the signature generation method is implemented on the frontend, the token may be leaked. Therefore, to safeguard your security, we recommend that you do not implement signature generation on the frontend.
const signature =sha256(timestamp + config.token + config.appid + timestamp).toUpperCase();// Use the token and APP ID obtained above to generate an encrypted string and return it
After deploying the signature service, add a signature acquisition method to your webpage for the SDK to connect to and call.
Web
Mini program
asyncfunctiongetSignature(){
const res =awaitfetch('Your domain/get-ar-sign')
const authdata =await res.json()
console.log('authdata',authdata)
return authdata
}
asyncfunctiongetSignature(){
returnnewPromise((resolve,reject)=>{
wx.request({
url:'Your domain/get-ar-sign',
method:'GET',
success(res){
console.log('getSignature ok', res)
resolve(res.data);
},
fail(e){
console.log('getSignature error', e)
}
})
})
}
SDK Integration
After completing the above preparations, follow the process below to connect to and use the SDK.
Process description
The Tencent Effect web SDK offers simple and minimally invasive APIs. To integrate it and use its features, you only need to initialize an instance and add the render node to your webpage.
Installing the SDK
The SDK is offered as an npm package.
npminstall tencentcloud-webar
In addition, you can also use it for your project by importing JS.