Make Easier User Authentication Processes (even on Cross Platforms and Cross Apps) | Huawei Keyri...
Tags: android, crossplatform, google, keyring
Published: 2022-05-18 13:44:52

---
title: Make Easier User Authentication Processes (even on Cross Platforms and Cross Apps) | Huawei Keyri...
published: true
date: 2022-04-21 15:58:12 UTC
tags: android,crossplatform,google,keyring
canonical_url: 
---

### Make Easier User Authentication Processes (even on Cross Platforms and Cross Apps) | Huawei Keyring vs Google Identity Smart Lock for Passwords

![](https://cdn-images-1.medium.com/max/1024/0*sHiJRWIiIAcA8D_V)
_Source_

Hi folks 👋, I have a question for you ❓

> 🤔 💭 Imagine you own a company such as Meta ( ex-Facebook). So you have a lot of apps/projects such as Facebook, WhatsApp, Instagram. Sometimes your users forget the account/passsword of your apps so they can’t log in to the app. And they try to “Forget Password” functionality of your apps. They try to recover their passwords. They spend time on that. This causes a non-easy and non user-friendly app experience for users. Also, your Forget Password service get a lot of requests and it is a cost for you.

<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FIgLIVXrBcID9cExa6r%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FIgLIVXrBcID9cExa6r%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FIgLIVXrBcID9cExa6r%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="435" frameborder="0" scrolling="no"><a href="https://medium.com/media/ebc2f5a06f3f52804bf8e99797d42181/href">https://medium.com/media/ebc2f5a06f3f52804bf8e99797d42181/href</a></iframe>

> 🤔 You come up with a brilliant idea; **Sharing Credentials**. You want to ease the authentication process of users by sharing credentials between cross apps and cross platforms such as Android Apps-Websites. Users will be needed just remember one password when they can **share credentials between your projects**. How would you do this❓

#### **Introduction**

🔎 In this article, we will look for answers to this question both on devices that have HMS Core and devices that have Google Play Services.

Huawei Keyring Service fully matches your requirements. Let’s look at it.

### 🔑🔐 Huawei Keyring

The Keyring is an SDK provided by Huawei which allows you to store user credentials locally on Android phones, tablets and also share these credentials between different apps and even platforms such as websites and quick apps.

> Keyring provides [APIs for android apps](https://developer.huawei.com/consumer/en/doc/development/Security-References/overview-0000001133344960), [APIs for web apps](https://developer.huawei.com/consumer/en/doc/development/Security-References/javascript-overview-0000001214568685), and [APIs for quick apps](https://developer.huawei.com/consumer/en/doc/development/quickApp-Guides/quickapp-access-keyring-kit-0000001161177180). Apps can integrate relevant APIs to use Keyring. All user credentials will be **stored in HMS Core Keyring** regardless of which type of APIs you are calling, implementing unified **credential management and sharing**.

![](https://cdn-images-1.medium.com/max/989/0*7Z-D57pOBzbTb6SH)
_How Keyring works with different platforms_

#### 💾🔏Storing & Retrieving Credentials Securely
<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2F110dhxfJebYOTm%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2F110dhxfJebYOTm%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2F110dhxfJebYOTm%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="278" frameborder="0" scrolling="no"><a href="https://medium.com/media/b9c01a1ccf54591de29db932b04792a2/href">https://medium.com/media/b9c01a1ccf54591de29db932b04792a2/href</a></iframe>

The Keyring stores user credentials **on the user device** for automatic sign-in later. The Keyring **encrypts** the credentials and stores them on the HMS Core. Additionally, while you save a credential you can pass true to **_userAuth_** variable of a Credential instance in order to request[**Biometric Verification**](https://github.com/Explore-In-HMS/Explore-Landmarks/blob/master/art/01Login/04BiometricAuth.png) **or Lock Screen Password** when an app tries to access this credential.

> When an app/platform tries to access a credential which **userAuth** variable given true, the **Keyring SDK** will handle user authentication by [**Biometric Verification**](https://github.com/Explore-In-HMS/Explore-Landmarks/blob/master/art/01Login/04BiometricAuth.png) **or Lock Screen Password**. The app/platform can’t access the password of the credential until the authentication has been successfull.

Also, you can save **multiple credentials**. So that provides multiple login options to the user.

#### 📱📲 Cross-App SignIn & 💻📲 Cross-Platform SignIn ( SHARING CREDENTIALS )

![](https://cdn-images-1.medium.com/max/512/1*esctU4Kz1ZamW8Ok1R-Ayw.png)
_Sharing Credentials_

You can pass app and website identities which you want to share this credential with them to _sharedWith_ variable while creating a credential instance to save. So you can define other android apps, websites, and quick apps in order to share user credentials securely.

![](https://cdn-images-1.medium.com/max/944/1*poOCD4KDgdyrNthbASwWnA.png)
_For sharing a credential securely with other platforms you need some basic information_

You can get credentials shared with your app in addition to saved by your app while retrieving the credential list. You need to pass a _trustedAppList_ to your request -such as saving a credential process- in order to define which platforms (android app, website, quick app) trusted your app and has possibly shared some credentials with your app.

**For instance;** A user logged into Instagram. And Instagram saved the user credentials with a _trustedAppList_. Suppose this _trustedAppList_ includes a Facebook android app, Facebook Website, and WhatsApp android app identities. The Facebook Android app will try to retrieve saved credentials from HMS Core when the user enters the Facebook android app. If the Facebook android app passes Instagram app identities in a _trustedAppList_ while retrieving saved credentials, it will be able to obtain saved credentials from the Instagram app to HMS Core. After then the Facebook app will show obtained list and the **user will be able to select the Instagram credentials to log in Facebook app**.

> One credential two different apps. Seamless & Effortless user experience. That’s the power of Keyring.

Note; the _trustedAppList_ can be different while saving credentials and obtaining the credential list. It doesn’t have to be the same. For instance, when you save CredentialA you can pass 3 Identities to share this credential. And when saving CredentialB you can pass just 1 Identity. Even you can pass nothing -just the app which saved the credential can retrieve it. When you retrieve the saved credential list you can pass 5 Identity. No problem. Just customize as your needs (Which platforms do you want to share Credential with? Which platforms/apps possibly shared credentials with you?).

#### 💪Supported Devices

![](https://cdn-images-1.medium.com/max/1014/1*OiL4PgvbsZ4wx1Gsy3Vgpg.png)
_Devices that can use Keyring_

Devices must have HMS Core to use Keyring Service. The keyring is so cool solution for our needs to ease our customer's life and reduce our web request cost. That’s nice but is there any solution for devices that have Google Play Services instead of HMS Core.

### 🔑Google Identity Smart Lock for Passwords

This SDK provides programmatically **saving and retrieving credentials** and automatically signs users in across devices and websites.

> Note; for updated user experience and other improvements, Google recommends using One Tap instead of Smart Lock for Password if One Tap sign-in meets your needs. But keep in mind, One Tap has no feature such as sharing credentials between apps or websites.

![](https://cdn-images-1.medium.com/max/1024/1*0aMirnu556HE-o9pdYkkVQ.png)

#### 💾 Storing & Retrieving Credentials

![](https://cdn-images-1.medium.com/max/512/1*5NiZ2BNyZJhYaUnMYc1jzw.png)
_Storage on mobile devices_

You can specify sign-in systems with password-based sign-in or [commonly-used sign-in providers](https://developers.google.com/android/reference/com/google/android/gms/auth/api/credentials/IdentityProviders) such as Google, and Twitter Sign-In while retrieving the credentials or saving a credential.

Smart Lock for Password [**requests confirmation from the user**](https://developers.google.com/identity/smartlock-passwords/android/store-credentials#store_credentials) for storing credentials. If the user chooses not to save credentials, the user won’t be prompted again to save any account’s credentials for the app. The user can opt-in later from the Google Settings app, in the Smart Lock for Passwords section. There is no such thing in Keyring.

Smart Lock for Passwords doesn’t provide a credential list that includes all saved credentials. Instead, it [throws exceptions](https://developers.google.com/identity/smartlock-passwords/android/retrieve-credentials#handle_multiple_saved_credentials) if has multiple credentials or no credentials. Then you should handle these states to call the appropriate APIs or show appropriate screens. You should call _startResolutionForResult()_ when multiple credentials exist. Then the SDK will **show saved credentials in the UI** to prompt the user to choose an account. You will retrieve the selected credential when the user chooses any credential in the UI.

#### 💻📲 Sharing Credentials

Smart Lock for Passwords provides you with that sharing of credentials between apps and websites to automatically sign in.

> But there is **no feature** such as **sharing credentials between android apps**. For that you should use Content Providers.

To associate an app with a website, you need to declare associations by hosting a **Digital Asset Links JSON file** on your website, and adding a link to the Digital Asset Link file to your app’s manifest. And also your website’s sign-in domain must be available through **HTTPS**. And your **app needs to be released in the public channel** for associations to be picked up.

#### 💡 Sign-In Hints & Autofill
<iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2Fl1KVaST85EIicDiLe%2Ftwitter%2Fiframe&amp;display_name=Giphy&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2Fl1KVaST85EIicDiLe%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2Fl1KVaST85EIicDiLe%2Fgiphy.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="324" frameborder="0" scrolling="no"><a href="https://medium.com/media/db5e15b9437c1b861a1303ccc56529d1/href">https://medium.com/media/db5e15b9437c1b861a1303ccc56529d1/href</a></iframe>

Smart Lock for Passwords provides sign-in **hints** such as the user’s name and email address when retrieving user credential requests fail. When you save password credentials using Smart Lock on devices running Android O or newer, Smart Lock uses the native **autofill confirmation dialog** over its own dialog whenever possible.

### 🔑🔐 Huawei Keyring vs Google Identity Smart Lock for Passwords

![](https://cdn-images-1.medium.com/max/1024/1*V3JBmD0Vt6U4_n9TDWWolw.png)
_Huawei Keyring vs Google Identity Smart Lock for Passwords_

> [You can view the excel table more detailly by clicking here.](https://docs.google.com/spreadsheets/d/1SjSrqZMsKUJr4d6aXsbfakU_KSHJq93W/edit#gid=858545918)

#### 🔚 💚 👏 Conclusion

In this article, we learned how we can make easier our customer’s authentication processes. And also we compared Huawei Keyring Service and Google Identity Smart Lock for Password SDK. I hope it is helpful and informative for you. Don’t hesitate to [contact me](https://www.linkedin.com/in/cengiztoru/) if you find some wrong information. Thanks for reading. Have a healthy life. See you in the next articles👋.

(Don’t forget breaking the clap button 😊)

### REFERENCES

References in the table

- [Document](https://developer.huawei.com/consumer/en/doc/development/Security-References/credential-0000001133185188)
- [Document](https://developer.huawei.com/consumer/en/doc/development/Security-References/credentialtype-0000001179304561)
- [IdentityProviders | Google Play services | Google Developers](https://developers.google.com/android/reference/com/google/android/gms/auth/api/credentials/IdentityProviders)

#### Keyring

- [Explore-Landmarks/CredentialManagementViewModel.kt at master · Explore-In-HMS/Explore-Landmarks](https://github.com/Explore-In-HMS/Explore-Landmarks/blob/master/app/src/main/java/com/hms/explorelandmarks/ui/authentication/CredentialManagementViewModel.kt)
- [Keyring](https://developer.huawei.com/consumer/en/hms/huawei-keyring/)
- [Document](https://developer.huawei.com/consumer/en/doc/development/Security-Guides/introduction-0000001133141068)
- [👨🏼‍💻 Manage Your Credentials with Huawei Keyring](https://medium.com/huawei-developers/manage-your-credentials-with-huawei-keyring-ac7f2d82b4ac)
- [Shares the user’s credentials between your Android apps, quick apps, and web apps using Huawei…](https://basavarajnavi.medium.com/shares-the-users-credentials-between-your-android-apps-quick-apps-and-web-apps-using-huawei-cb4f8a69ddac)

#### Smart Lock for Passwords

- [Google Identity | Google Developers](https://developers.google.com/identity)
- [Smart Lock for Passwords on Android | Google Developers](https://developers.google.com/identity/smartlock-passwords/android)
- [Enable automatic sign-in across apps and websites | Smart Lock for Passwords on Android | Google Developers](https://developers.google.com/identity/smartlock-passwords/android/associate-apps-and-sites)

* * *