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

Login Using an App ID

1
HWMSdk.getOpenApi.loginByAppId(AppIdAuthParam,HwmCallback)

API Description

This API is used for login using an app ID.

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 appIdAuthParam Indicates the appIdAuthParam object.
     * @param hwmCallback Indicates the result callback.
     */
void loginByAppId(AppIdAuthParam appIdAuthParam HwmCallback<LoginResult> hwmCallback)

Parameter Description

Table 1 Parameter description

Parameter

Mandatory

Type

Description

appIdAuthParam

Yes

AppIdAuthParam

appIdAuthParam object.

hwmCallback

Yes

HwmCallback<LoginResult>

Callback object.

Return Values

None

Parameter Extension

Table 2 AppIdAuthParam parameters

Parameter

Mandatory

Type

Description

thirdUserId

Yes

String

Unique ID of a third-party account. The value is a string of 1 to 64 characters.

Note: When the app ID authentication mode is used, ensure that the app ID has been applied for on the meeting server. When the app ID is passed using HWMSdk.init, the OpenSdkConfig parameter must be transferred using OpenSdkCOnfig.setAppId(appid).

nonce

Yes

String

A random character string consisting of 32 to 64 characters.

corpId

No

String

ID of the enterprise to which the user belongs. This parameter is mandatory only in SP mode. Do not set this parameter in single-enterprise mode. Otherwise, the authentication will fail.

signature

Yes

String

Signature information.

expireTime

Yes

long

Signature expiration time. The value is a Unix timestamp, in seconds. If the value is 0, the signature will not expire.

userName

No

String

Username. If this parameter is left blank, the value of this parameter is the same as that of thirdUserId by default.

userEmail

No

String

Email address of the user.

userPhone

No

String

Mobile number of the user.

deptCode

No

String

Department code.

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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Create a login object.
AppIdAuthParam appIdAuthParam = new AppIdAuthParam();
// Set the signature expiration time. The value is a Unix timestamp, in seconds. If the value is 0, the signature will not expire.
appIdAuthParam.setExpireTime(1599618620);
// Set a random character string consisting of 32 to 64 characters.
appIdAuthParam.setNonce("602b111272ad4b6989e683c27e6e87d4");
// Set the ID of the enterprise to which the user belongs. This parameter is required only in the SP login scenario.
appIdAuthParam.setCorpId(123);
// Set the ID of the third-party account. The value contains 1 to 64 characters.
appIdAuthParam.setUserId("admin@1");
// Set signature information.
appIdAuthParam.setSignature("2a8c780cee3dbfe210384c3f95380732d55dfc81cfa49c5a6c44f3c1b3c2455d");
// Set the user nickname.
appIdAuthParam.setUserName("Mike");
// Set the email address, which must meet the format requirements.
appIdAuthParam.setUserEmail("huawei123456@huawei.com");
// Set the mobile number, which must be in the correct format, for example, ^$|^[+]?[0-9]+$.
appIdAuthParam.setUserPhone("12345678901");
// Start to log in.
HWMSdk.getOpenApi(getActivity().getApplication()).loginByAppId(appIdAuthParam, new HwmCallback<LoginResult>() {
            @Override
            public void onSuccess(LoginResult loginResult) {
                dismissLoading();
                dismiss();
                if (loginResult != null) {
                    DemoUtil.showToast("Login succeeded" + loginResult.getUserUuid());
                }else{
                    DemoUtil.showToast("Logged in");
                }
            }

            @Override
            public void onFailed(int retCode, String desc) {
                HwmContext.getInstance().runOnMainThread(() ->{
                    dismissLoading();
                    Error error = HWMBizSdk.getLoginApi().convertErrorCodeToUI(retCode);
                     DemoUtil.showToast("Login failed: "+ getLoginErrTips(error));
                    dismiss();
                });
            }
        });