dawid86 / huawei-account-demo

Sample code for quickly integrate Huawei ID. HUAWEI Account Kit provides developers with simple, secure, and quick sign-in and authorization functions.

Home Page:https://developer.huawei.com/consumer/en/hms/huawei-accountkit?ha_source=hms1

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

HUAWEI Account Demo

English | 中文

Table of Contents

Introduction

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.

Installation

To use functions provided by examples, please make sure Huawei Mobile Service 4.0 has been installed on your cellphone.

Supported Environments

Android SDK Version >= 23 and JDK version >= 1.8 is recommended.

Configurations

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.

Sample Code

The Account-Server-Java-Demo provides demonstration for following scenarios:

  1. Authorization code to obtain Access Token.
  2. Verify the ID Token with public key.
  3. 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:

  1. ID-Token Mode Sign In.
  2. Authorization Code Mode Sign In.
  3. Silent Sign In
  4. Sign Out.
  5. Cancel Authorization.

The service logic of ID-Token Mode Sign In and Authorization Code Mode Sign In are implemented in AccountActivity.java.

Result

The Account-Server-Java-Demo print the result of access token, jwt and content of access token.

Question or issues

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.

License

Account-kit Android sample is licensed under the Apache License, version 2.0.

About

Sample code for quickly integrate Huawei ID. HUAWEI Account Kit provides developers with simple, secure, and quick sign-in and authorization functions.

https://developer.huawei.com/consumer/en/hms/huawei-accountkit?ha_source=hms1