We use essential cookies for the website to function, as well as analytics cookies for analyzing and creating statistics of the website performance. To agree to the use of analytics cookies, click "Accept All". You can manage your preferences at any time by clicking "Cookie Settings" on the footer. More Information.

Only Essential Cookies
Accept All
GuidesAccount KitFAQs

FAQs

Content overview
Expand

Need more help? Go to Stack Overflow.

Signing In

Can I use Account Kit if I have my own account management system?

Yes, certainly. It is a common scenario.

How can I make my app support HUAWEI ID sign-in on devices without HMS Core (APK)?

The AppAuth SDK will help you achieve what you want. For details, please refer to For Android Apps.

When my app is running on non-Huawei phones with HMS Core (APK) installed, can users sign in to my app with their HUAWEI IDs?

The answer is certainly yes.

A HUAWEI ID user signs out of my app and then signs in again, but my app does not ask the user to enter account information. Why?

Though the user signs out, the HUAWEI ID is actually still in signed-in state on your app, because the user has authorized your app. Therefore, it's normal that your app does not require input of account information from the user when he/she signs in again. The user has to enter necessary information for signing in, if he/she has done either of the following:

  • Logged the HUAWEI ID out of the device. (How to log out: Go to Settings > Account center and tap LOG OUT.)
  • Canceled authorization to your app. (How to cancel: Go to Settings > Account center > Privacy center > Control account access, then select your app, and tap CANCEL AUTHORIZATION.)

My app appears in full-screen mode and it calls the sign-in API to bring up the sign-in screen, but the status bar at the top of the device screen flashes by. Why does this happen?

Full-screen adaptation is not made for a page in the Account SDK. To resolve this issue, do as follows:

  1. Update the Account SDK to 6.1.0.302 or later.
  2. Make sure that the sample code used for integrating the sign-in API is similar to the following:
Java
Collapse
Word wrap
Dark theme
Copy code
  1. public void accountAuthSignIn() {
  2. AccountAuthParams authParams = new AccountAuthParamsHelper(AccountAuthParams.DEFAULT_AUTH_REQUEST_PARAM).setAuthorizationCode().createParams();
  3. AccountAuthService service = AccountAuthManager.getService(MainActivity.this, authParams);
  4. Intent intent = service.getSignInIntent();
  5. intent.putExtra(CommonConstant.RequestParams.IS_FULL_SCREEN, true);
  6. startActivityForResult(intent, 8899);
  7. }

Obtaining Account Information

What are the maximum lengths of access token and refresh token?

The lengths of access token and refresh token are related to the information encoded in the tokens. Currently, each of the two tokens contains a maximum of 1024 characters.

Is there a limit on the frequency for calling the API for obtaining the access token?

This API can be called by an app up to 10,000 times within one hour. If the app exceeds the limit, it will fail to obtain the access token.

The email address is contained in the account information, but is not found in the response to the /oauth2/v3/tokeninfo API call from the Huawei Account Kit server. Why?

Description

After integrating Account Kit, I call the /oauth2/v3/tokeninfo API of the Account Kit server to obtain the ID token, but can't find the email address in the response body.

The response in this case is as follows:

Collapse
Word wrap
Dark theme
Copy code
  1. {
  2. "at_hash": "XXXXXX",
  3. "aud": "XXXXXX",
  4. "sub": "XXXXXX",
  5. "azp": "XXXXXX",
  6. "kid": "XXXXXX",
  7. "iss": "https://accounts.huawei.com",
  8. "typ": "JWT",
  9. "exp": 1579682457,
  10. "display_name": "136******53",
  11. "iat": XXXXXX,
  12. "alg": "RS256"
  13. }

The response in the API reference is as follows:

Collapse
Word wrap
Dark theme
Copy code
  1. {
  2. "iss":"String",
  3. "sub":"String",
  4. "aud":"String",
  5. "exp":"Long",
  6. "iat":"Long",
  7. "nonce":"String",
  8. "at_hash":"String",
  9. "azp":"String",
  10. "email_verified":"Boolean",
  11. "email":"String",
  12. "picture":"String",
  13. "name":"String",
  14. "locale":"String",
  15. "family_name":"String",
  16. "given_name":"String",
  17. "display_name":"String"
  18. }

Possible Causes

Before obtaining the ID token, the app does not request the HUAWEI ID user to authorize the app to obtain the email address.

Procedure

In the client-side code of your app, call the related API to request the HUAWEI ID user to authorize the app to obtain the email address.

The authorization request API in Account SDK 3.0 is requestEmail(), and that in Account SDK 4.0 is setEmail().

  • Account SDK 3.0
    Collapse
    Word wrap
    Dark theme
    Copy code
    1. HuaweiIdSignInOptions mSignInOptions = new HuaweiIdSignInOptions.Builder(HuaweiIdSignInOptions.DEFAULT_SIGN_IN).requestServerAuthCode().requestIdToken("").requestEmail().build();
  • Account SDK 4.0
    Collapse
    Word wrap
    Dark theme
    Copy code
    1. HuaweiIdAuthParams authParams = new HuaweiIdAuthParamsHelper(HuaweiIdAuthParams.DEFAULT_AUTH_REQUEST_PARAM).setIdToken().setEmail().createParams();
NOTE

For details about how to request a HUAWEI ID user to authorize an app to obtain the email address, please refer to setEmail in HuaweiIdAuthParamsHelper.

Is a private key required when jwt.io is used to verify an ID token?

No private key is required for verifying or parsing an ID token.

After the on-device ID token verification code in the sample code is executed, an error message "id Token validate failed.NoSuchMethodError" is displayed. Why?

The minimum Android version for the ID token-based integration demo is Android 9. Check whether the Android version on the test phone is the required version.

The account information has been obtained after a successful callback on the device. Then I called getEmail() to obtain the email address from the account information, but didn't find the email address. Why?

The email address is not mandatory. Sign in to the account center to check whether the user's account information contains the email address.

What is the update policy of the public key used to verify the validity of the ID token? When will the public key be updated? Will the old public key cached by me be unavailable after the update?

The public key used to verify the ID token is updated once a day and can be cached on your app server. If the public key is invalid, obtain the latest public key from certs and update the public key cached on the app server.

Can I obtain the UID after integrating Account Kit?

No. For privacy protection, you can obtain only the OpenID and UnionID.

What are the lengths of OpenID and UnionID?

OpenID: Currently, the OpenID returned by the Account Kit server does not have a fixed length, but the maximum length allowed is 256 characters. For future expansion considerations, reserve at least 768 (256 x 3) characters for the OpenID. Actually, you are advised not to set any length limit for the OpenID.

UnionID: Currently, the UnionID returned by the Account Kit server consists of 46 characters, and the maximum length allowed is 64 characters. For future expansion considerations, reserve at least 192 (64 x 3) characters for the UnionID. Actually, you are advised not to set any length limit for the UnionID.

NOTE

The difference between UnionID and OpenID lies in that if multiple apps are managed under the same developer ID, the OpenID varies depending on the apps, but the UnionID is the same for all the apps. If you need to share the user information of the same HUAWEI ID across different apps, use UnionID as the user ID.

How long will the access token and refresh token be valid?

The validity period of the access token is 1 hour, and that of the refresh token is 180 days.

Others

A user has installed the latest HMS Core (APK) on their phone running Android 11, but they were still asked to update the APK. How should I resolve this issue?

In Android 11, the way for an app to query other apps on the user device and interact with them has been changed. If targetSdkVersion is 30 or later for your app and the Account SDK integrated into your app is earlier than 6.1.0.300, your app will be unable to access HMS Core (APK) and continuously ask users to update the APK.

You can solve the issue using either of the following methods:

  • Method 2:

    If the SDK is not updated, add a <queries> element in the manifest element in AndroidManifest.xml.

    Collapse
    Word wrap
    Dark theme
    Copy code
    1. <manifest ...>
    2. ...
    3. <queries>
    4. <intent>
    5. <action android:name="com.huawei.hms.core.aidlservice" />
    6. </intent>
    7. </queries>
    8. ...
    9. </manifest>
    NOTE

    The <queries> element requires the following:

    • Your Android Studio version is 3.3 or later.
    • Your Android Gradle plugin version is 3.3.3, 3.4.3, 3.5.4, 3.6.4, 4.0.1, 4.1.0, or later.
Search in Guides
Enter a keyword.