English | 中文
- Introduction
- Installation
- Environment Requirements
- Configuration
- Sample Code
- Result
- Technical Support
- License
The sample code for Android encapsulates the server-side APIs of Account Kit, containing multiple demo apps for your reference or direct use. The sample code offers: hmssample: sample code package, which implements the following functions: sign-in, authorized sign-in, and sign-out logger: records logs.
To use capabilities offered in the sample code, make sure that HMS Core (APK) 4.0 has been installed on your device.
Android SDK version: 23 or later
JDK version: 1.8 or later
Parameters in Contant.java include: CLIENT_ID: app ID, which can be obtained from AppGallery Connect CERT_URL: public key. To get it, obtain the public key URI from jwks_uri and then access this URI. ID_TOKEN_ISSUE: same as the value of iss in the ID token
The Java sample code for the server-side shows how to implement the following functions:
- Use the authorization code to obtain the access token in TokenAPIDemo.java.
- Use the public key to verify the ID token in IDTokenAPIDemo.java.
- Parse the access token in GetTokenInfoAPIDemo.java.
The Java sample code for the client-side shows how to implement the following functions:
- Sign-in in ID token mode.
- Sign-in in authorization code mode.
- Silent sign-in.
- Sign-out from an ID.
- Authorization revocation.
Service logic: Implement sign-in in ID token mode and authorization code mode in AccountActivity.java.
The server-side Java sample code prints the access token and JSON Web Token.
You can visit the Reddit community to obtain the latest information about HMS Core and communicate with other developers. If you have any questions about the sample code, try the following:
-
Visit Stack Overflow, submit your questions, and tag them with
huawei-mobile-services
. Huawei experts will answer your questions. -
Visit the HMS Core section in the HUAWEI Developer Forum and communicate with other developers.
If you encounter any issues when using the sample code, submit your issues or submit a pull request.
The sample code is licensed under Apache License 2.0.