Account Kit provides you with simple, secure, and quick sign-in and authorization functions. Instead of entering accounts and passwords and waiting for authentication, users can just tap the Sign in with HUAWEI ID button to quickly and securely sign in to your app with their HUAWEI IDs.
Platform | Device Type | OS version | HMS Core(APK) version |
---|---|---|---|
Android | Phone, tablet, HUAWEI Vision, and telematics device | EMUI 3.0 or later, Android 4.4 or later | 4.0.0.300 or later |
HarmonyOS (Java) | Phone and tablet | HarmonyOS 2.0 or later | 5.0.0.300 or later |
Telematics device | HarmonyOS 2.0 or later | 6.2.0.300 or later | |
HUAWEI Vision and smart watch | HarmonyOS 2.0 or later | 6.5.0.300 or later | |
HarmonyOS (JavaScript) | Phone and tablet | HarmonyOS 2.0 or later | 5.0.0.300 or later |
Telematics device | HarmonyOS 2.0 or later | 6.2.0.300 or later | |
HUAWEI Vision and smart watch | HarmonyOS 2.0 or later | 6.5.0.300 or later |
Serves more than 190 countries and regions, and supports more than 70 languages.
-
Quick and standard
Connects your app to the Huawei ecosystem, allowing users to sign in to your app with their HUAWEI IDs from a range of devices, such as phones, tablets, HUAWEI Vision products, and telematics devices. -
Secure, reliable, and compliant with international standards
Complies with GDPR and industry-standard protocols such as OAuth 2.0 and OpenID Connect; supports two-factor authentication (password plus verification code) to ensure high security; notifies users of possible risks in real time.
Users can quickly and conveniently sign in to apps with their HUAWEI IDs. When signing in to an app using a HUAWEI ID for the first time, a user needs to authorize the app. Then, the user can sign in to the app with one tap. With one HUAWEI ID, a user can sign in to all apps on all devices.
With Account Kit, the user who has already signed in with his/her HUAWEI ID on a device can easily sign in with the same ID on other devices by scanning a QR code.
Before integrating Account Kit into your app, you will need to sign the HUAWEI Developers Service Agreement and Agreement on Use of Huawei APIs. You understand and accept that downloading or using the said kit will be deemed as you having agreed to all of the preceding agreements, and you will fulfill and assume the legal responsibilities and obligations in accordance with said agreements.
Before you get started, you must register as a HUAWEI developer and complete identity verification on the HUAWEI Developer website. For details, please refer to Register a HUAWEI ID.
Create an app by referring to Creating a Project and Creating an App in the Project. Set the following parameters as described:
- Platform: Select Android
- Device: Select Mobile phone
- App category: Select App or Game
According to HMS integration process introduction, we still need to add some configurations to the gradle files for development preparations.
-
Install the Plugin
Copy and enable the Unreal Engine Plugin.
If a
<unreal_project_directory>/Plugins
folder does not exist, create it.From the Huawei Account Unreal plugin, copy the HuaweiAccount folder and its contents to
<unreal_project_directory>/Plugins
.From your Unreal Editor, select Edit -> Plugins menu then enable the Huawei Account Plugin.
-
Signing Certificate Fingerprint
Please refer to Huawei preparation documentation step 4 for generating a SHA256 Certificate Fingerprint.
And refer to Huawei preparation documentation step 5 to add Fingerprint to AppGallery Connect.
-
Package name
Set the package name in Edit -> Project Settings -> Android -> APK Packaging -> Android Package Name
The package name is
com.${Company Name}.${Product Name}
.You can also complete the rest of the settings here, such as version number, icons, resolution, etc.
-
Set up plugin
- Sign in to AppGallery Connect and click My projects.
- Find your app project and click the app that needs to integrate the HMS Core SDK.
- Go to Project settings > General information. In the App information area, download the
agconnect-services.json
file. - You can put the json file under
<unreal_project_directory>/Configs/AGC
as default (create theConfigs/AGC
directory if not existed) or in your own favorite path - In your Unreal Editor, select Edit -> Project Settings -> Plugins -> HuaweiAccount then set up the
agconnect-services.json
file path
The below functions are supported with Blueprint
loginWithoutVerification
loginWithIdToken
loginWithAuthorizationCode
logOut
cancelAuthorization
You can refer to the Blueprint sample.
Access the Huawei Account APIs by including the header file Account.h
in the related classes of your project.
#include "Account.h"
- Log in without identity verification
huawei::Account::loginWithoutVerification();
- Log in via ID Token(OpenID connect)
Sample code
huawei::Account::loginWithIdToken();
- Log in via Authorization Code(OAuth 2.0)
Sample code
huawei::Account::loginWithAuthorizationCode();
- Log out
Sample code
huawei::Account::logOut();
- Cancel authorization
Sample code
huawei::Account::cancelAuthorization();
- Listen to callback events Implement a listener class to receive information in all the Account callback events
Action types table:
Type |
Description |
---|---|
LOGIN_ACTION | Login without ID verification |
LOGIN_BY_ID_TOKEN_ACTION | Login via ID token(OpenID connect) |
LOGIN_BY_AUTH_CODE_ACTION | Login via Authorization Code(OAuth 2.0) |
LOGOUT_ACTION | Logout |
CANCEL_AUTH_ACTION | Cancel authorization |
Sample code Header file
class YourAccountListener : public huawei::AccountListener {
public:
YourAccountListener();
void onLoggedIn(const AccountInfo account);
void onGetIdToken(const FString idToken, const AccountInfo account);
void onGetAuthCode(const FString authCode, const AccountInfo account);
void onLoggedOut();
void onCancelledAuth();
void onException(int action, const FString message);
}
Then set it with the setListener
API
Sample code
huawei::Account::setListener(new YourAccountListener());
You can get the below account information
Type |
Description |
---|---|
displayName | user's nickname |
avatarUriString | user's profile picture URI |
user's email address if user authorizes, otherwise null will be returned | |
openId | user's openID (identifies a user in a app) |
unionId | user's unionID (identifies a user accross all your apps) |
If you use loginWithIdToken
API, you have to verify the obtained ID token on your server. Please refer to this guide for more detailed.
If you use loginWithAuthorizationCode
API, you have to verify the obtained Authorization code on your server. Please refer to this guide for more detailed.
Please refer to Huawei integration procedure for testing and releasing.