To protect user privacy, the Wear Engine APIs need user authorization to work. It is recommended that you perform the operations in this section when users call Wear Engine's open capabilities for the first time.
Your app can only access data upon user authorization on the HUAWEI ID sign-in screen and authorization screen. Users can select the data range to be authorized and grant only some data permissions.

// Before using Wear Engine, import Wear Engine and related modules.
import { wearEngine } from '@kit.WearEngine';
import { BusinessError } from '@kit.BasicServicesKit';
// Step 1: Obtain the AuthClient object.
let authClient: wearEngine.AuthClient = wearEngine.getAuthClient(getContext(this));
// Step 2: Define the permission request class based on the permissions that require user authorization.
let request: wearEngine.AuthorizationRequest = {
permissions: [wearEngine.Permission.USER_STATUS]
}
// Step 3: Request user authorization.
authClient.requestAuthorization(request).then(result => {
console.info(`Succeeded in requesting authorize, authorized permissions is ${result.permissions}`);
}).catch((error: BusinessError) => {
console.error(`Failed to request authorize. Code is ${error.code}, message is ${error.message}`);
}) This API is used to query the app permissions granted by a user. If the required permissions are not granted, request authorization from the user by referring to Applying for Wearable Device Permissions. You are advised to use this API to check whether the required permissions have been granted before requesting user authorization.
Ensure that the permissions have been approved after applying for integrating Wear Engine. Otherwise, error code 1008500004 will be reported.
// Before using Wear Engine, import Wear Engine and related modules.
import { wearEngine } from '@kit.WearEngine';
import { BusinessError } from '@kit.BasicServicesKit';
// Step 1: Obtain the AuthClient object.
let authClient: wearEngine.AuthClient = wearEngine.getAuthClient(getContext(this));
// Step 2: Call the API to query granted permissions.
authClient.getAuthorization().then(result => {
console.info(`Succeeded in getting authorized permissions, authorized permissions is ${result.permissions}`);
}).catch((error: BusinessError) => {
console.error(`Failed to get authorized permissions. Code is ${error.code}, message is ${error.message}`);
})