Updated on 2023-03-23 GMT+08:00

Scenario 2: Login

Description

You can use an app ID (for details about how to request an app ID, see Introduction to App ID Authentication) or Huawei Cloud Meeting account to log in to Huawei Cloud Meeting. The API for creating a meeting can be called only when you have logged in. To use complete meeting functions, log in to Huawei Cloud Meeting.

If you have not logged in, you can join only the meetings that have been created.

Service Process

Take app ID login as an example. Call the loginByAppId API and configure the API callback function onLoginResult when using the SDK to log in to the app.

  1. Call an API.

    1. Assemble the data structure AppIdAuthInfo and the API callback function onLoginResult.
    2. Call the loginByAppId API to log in. The data in the preceding step is used as input parameters.

  2. Implement the callback function.

    Implement the onLoginResult function.

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
* Login
*/
async goToLoginByAppId(){
   /**
    *. The data conversion performed by the third-party server is omitted here. The nonce and signature are obtained.
    */
    let param = {
      thirdUserId: "admin@1",
      userName: "Mike",
      signature: signature,
      nonce: nonce,
      expireTime: 1598398920,
      userEmail: "xxx@xxx.com",
      userPhone: "1234567890",
    }
    const apiService = new ApiService();
    let setResult = await apiService.loginByAppId(param);
    if(setResult.ret == 0){
      this.props.history.push('/main');
    }else{
      window.electron.ipcRenderer.send("show-error-alert", "loginByAppId error = " + setResult.ret);
    }
  }

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
/**
* Definition of loginByAppId API in ApiService
*/
async loginByAppId(appIdAuthInfo) {
    return new Promise((resolve) => {
      let resultCallback = (ret, reason, loginResult) => {
        console.log("loginByAppId, out data = ", { ret, reason, loginResult });
        resolve({ ret, reason, loginResult });
      };
      console.log("loginByAppId, in param = ", appIdAuthInfo);
      this.uisdkService.getLoginApi().loginByAppId(appIdAuthInfo, resultCallback);
    });
}