Updated on 2024-07-30 GMT+08:00

Login Using an Account and Password

1
HWMSdk.getOpenApi.login(LoginParam,HwmCallback)

API Description

This API is used to log in to Huawei Cloud Meeting.

Precautions

You can join a meeting anonymously. However, if you want to use other services, you must log in first.

After the login is successful, the callback onSuccess is invoked.

Method Definition

1
2
3
4
5
6
    /**
     * Logs in.
     * @param LoginParam Indicates the LoginParam object.
     * @param hwmCallback Indicates the result callback.
     */
void login(LoginParam loginParam HwmCallback<LoginResult> hwmCallback)

Parameter Description

Table 1 Parameter description

Parameter

Mandatory

Type

Description

loginParam

Yes

LoginParam

LoginParam object.

hwmCallback

Yes

HwmCallback<LoginResult>

Callback object.

Return Values

None

Parameter Extension

Table 2 LoginParam description

Parameter

Mandatory

Type

Description

account

Yes

String

Username.

password

Yes

String

Password.

nickName

No

String

Display name.

Table 3 LoginResult type description

Parameter

Type

Description

userUuid

String

User UUID, which is the unique user ID allocated by the system.

account

String

Login account.

thirdAccount

String

Third-party login account (in the app ID login scenario).

isFreeUser

boolean

Whether the user is a free user.

refreshToken

String

Refresh token.

siteDomain

String

Login domain name. This parameter is available only in site switchover scenarios. When a user selects the International site but uses a Chinese mainland account to log in, the system automatically switches to the Chinese mainland site and returns the domain name of the Chinese mainland.

Sample Code

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
// It is recommended that accounts and passwords used for authentication be stored in ciphertext in the configuration file or as environment variables and be decrypted during usage.
LoginParam loginParam = new LoginParam()        
    .setLoginAuthType(LoginAuthType.Account_And_Password)       // Set the login mode.
    .setAccount(getAccount())        // Login account
    .setPassword(getPassword());      // Login password
     
HWMSdk.getOpenApi(getActivity()).login(loginParam, new HwmCallback<LoginResult>() {             
     @Override             
     public void onSuccess(LoginResult loginResult) {  // Callback invoked upon a successful login.
         if (loginResult != null ) {                     
             Log.i(TAG, "Login succeeded" + loginResult.getUserUuid());
         }
     }              
     @Override             
     public void onFailed(int retCode, String desc) {   // Callback invoked upon a login failure.
        Error error = HWMBizSdk.getLoginApi().convertErrorCodeToUI(retCode);                 
        String errorTip = getLoginErrTips(error);               // Output the error cause based on the returned error value.
        Log.e(TAG, errorTip);     
     }        
});