English | 中文
Android sample code encapsulates APIs of the HUAWEI Account Kit server. It provides sample program for your reference or usage. The following describes of Android sample code.
hmssample: Sample code packages. This package contains code that implements Sign, SignInCode and SignOut. logger: This packages contains code that implements logger View.
To use functions provided by examples, please make sure Huawei Mobile Service 4.0 has been installed on your cellphone.
Android SDK Version >= 23 and JDK version >= 1.8 is recommended.
The following describes parameters in Contant.java CLIENT_ID: App ID, which can be obtained from AppGallery Connect website, please replace it with your app's client ID. CERT_URL: Request CERT_URL to get public key's URL from jwks_uri, then get public key. ID_TOKEN_ISSUE: The value that ISS string of ID Token should be equal to.
The Account-Server-Java-Demo provides demonstration for following scenarios:
- Authorization code to obtain Access Token.
- Verify the ID Token with public key.
- Parsing Access Token.
The business logic of obtain Access Token is implemented in TokenAPIDemo.java, Verify the ID Token is implemented in IDTokenAPIDemo.java, and Parse Access Token is implemented in GetTokenInfoAPIDemo.java.
This Account-Client-Java-Demo provides demonstration for following scenarios:
- ID-Token Mode Sign In.
- Authorization Code Mode Sign In.
- Silent Sign In
- Sign Out.
- Cancel Authorization.
The service logic of ID-Token Mode Sign In and Authorization Code Mode Sign In are implemented in AccountActivity.java.
The Account-Server-Java-Demo print the result of access token, jwt and content of access token.
If you want to evaluate more about HMS Core, r/HMSCore on Reddit is for you to keep up with latest news about HMS Core, and to exchange insights with other developers.
If you have questions about how to use HMS samples, try the following options:
- Stack Overflow is the best place for any programming questions. Be sure to tag your question with
huawei-mobile-services
. - Huawei Developer Forum HMS Core Module is great for general questions, or seeking recommendations and opinions.
If you run into a bug in our samples, please submit an issue to the Repository. Even better you can submit a Pull Request with a fix.
Account-kit Android sample is licensed under the Apache License, version 2.0.