Huawei Ability Gallery — Account Binding Solution 1

Yağmur Kılıç
Huawei Developers
Published in
3 min readJun 16, 2021

Introduction

In This article, we will learn how to implement the Card Ability — Huawei Account binding — solution 1 step by step.

Account Binding

Account binding refers to the process of binding a user’s HUAWEI ID and a developer’s account when developing card ability. Huawei provides three solutions to developers for account binding. We will work on solution-1 in this article.

if everybody is ready, let’s get started :)

Implementation

The account binding process consists of six phases in total. The scheme below will help you better understand the process of account binding.

  1. Enables Custom Sign Page — Account Binding Solution-1

Firstly, the developer server is mandatory for using solution-1. Huawei Ability Gallery sends the bind request to the developer’s server when custom sign mode is enabled from the Huawei phone.

2. Sends the Request to Obtain a Deep Link URL

/api/v1/users/bind is the address to which the binding or unbinding request from a Huawei ability gallery is sent. This address needs to be configured on the Fulfillment page in HUAWEI Ability Gallery. The request body of this service is in the following format.

OpenId: It is generated by Huawei Ability Gallery, using an app ID and a Huawei user ID.

Note: OpenId is unique for the same app and user.

3. Returns the Deep Link Of The Login Page

Deeplink needs to be created client-side has a specific syntax. This syntax should end with OpenID.

native app deep link example : app://com.huawei.hag/openId=xxxx

5. Authentication / Login with developer’s server

A deep link is created in the desired format. Afterward, the user redirects to the app sign-in page via the mentioned link.

The user enters the authorization credentials on the sign-in page. The sign-in page sends the credentials and OpenID to the developer’s server. OpenId is obtained from account binding response.

Once the developer’s server has verified the credentials, it will bind the developer’s account to the user’s OpenID.

6. Binding Operation

We need to “accessToken” for binding operation. We can obtain “accessToken” while creating an HTTP post request

huawei.hag.bindUrl=https://hag-eu.cloud.huawei.com/open-ability/v1/open-account-events/bind

Account Unbinding

If the user taps the account unbinding button, Huawei Ability Gallery sends the request to the developer server (/api/v1/users/bind).

The request body of unbinding operation is the same as the binding operation’s body. There is only one difference and that is the namespace.

The namespace must be “Deauthorization” for unbinding operations.

huawei.hag.unBindUrl=https://hag-eu.cloud.huawei.com/open-ability/v1/open-account-events/unbind

Conclusion

I hope this article helps you better understand Huawei Ability and account binding/unbinding operations.

Thanks for reading. If you have a question, don’t hesitate to contact me.

--

--