目录

Account

has.login

has.login(Object object)

Obtains the sign-in credential (code). The credential is used to obtain the user's sign-in status, including the unique identifier (openid) of the user in the current app and the unique identifier (unionid) of the user under the platform account. The session key is used to encrypt and decrypt user data.

Preparations

  1. Configure the signing information and add a fingerprint.

  2. Configure the client ID.

Since: 1.0.0

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

Return value of success

Parameter Type Description
code string Sign-in credential of the user (valid for 5 minutes).
idToken string User information in JWT format.
openID string Identifier of a HUAWEI ID user when using different apps. A user has different OpenIDs for different apps.
unionID string Identifier of a HUAWEI ID user in different apps of the same developer. A user has the same UnionID for different apps of the same developer.

Error code information

Error Code Error Message
11000101

1. state is invalid.

2. response data is null.

3. login error.

For details, see Account Management Error Codes.

Example:

has.login({
  success: (res) => {
    console.info('login success', res);
  },
  fail: (err) => {
    console.error('login fail', err);
  },
  complete: (res) => {
    console.info('login complete', res);
  }
});