Updated on 2024-07-30 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 description

Parameter

Mandatory

Type

Description

thirdUserId

Yes

String

Unique ID of a third-party account. The value contains 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(getNonce());
// Set the ID of the enterprise to which the user belongs. This parameter is required only in the SP login scenario.
appIdAuthParam.setCorpId(getCorpId());
// Set the ID of the third-party account. The value contains 1 to 64 characters.
appIdAuthParam.setUserId(getUserId());
// Set signature information.
appIdAuthParam.setSignature(getSignature());
// Set the user nickname.
appIdAuthParam.setUserName(getUserName());
// Set the email address, which must meet the format requirements.
appIdAuthParam.setUserEmail(getUserEmail());
// Set the mobile number, which must be in the correct format, for example, ^$|^[+]?[0-9]+$.
appIdAuthParam.setUserPhone(getUserPhone());
// 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();
                });
            }
        });