Open In App

How to Use Block Store to Do Smooth Account Transfers in Android?

Last Updated : 19 Sep, 2021
Improve
Improve
Like Article
Like
Save
Share
Report

When configuring a new Android smartphone, many users still maintain their own passwords. This manual procedure can be time-consuming and frequently results in a bad user experience. The Block Store API, a library backed by Google Play services, aims to address this by allowing apps to keep user credentials without the complexity or security risk that comes with saving user passwords. The enchantment of a new mobile gadget. Opening the crisp box, removing the plastic to see the blemish-free screen, setting up the smartphone, and having prior apps already downloaded onto the new device. This smooth experience is interrupted when the user attempts to utilize their applications and is required to re-authenticate. Trying to recall account credentials and going through account recovery procedures is time-consuming and inconvenient. This friction drives users to create a new account and abandon their old one, or in certain situations, the friction is so severe that they exit the program completely.

The following are some of the advantages of utilizing Block Store:

  1. For developers, an encrypted credential storage solution. When feasible, credentials are encrypted end-to-end.
  2. Instead of usernames and passwords, save tokens.
  3. Remove the friction from sign-in flows.
  4. Remove the burden of managing complicated passwords from users.
  5. Google authenticates the user’s identity.

The Block Store Operates as Follows

  1. You may save the authentication token that you produce for a user to Block Store when that user signs into your app or at any point after that.
  2. The token is encrypted and saved locally on the device once you save it with Block Store.
  3. When a user sets up a new device utilizing the device-to-device restore flow, data is moved across.
  4. When a user returns to your app on a new device, Block Store will obtain the token for your app if they have given the approval to restore their data via a device-to-device restore.

GeekTip: When using Block Store, the user is not restricted to the sort of credentials that may be utilized. Users may still utilize their login and password, their Google account, or any other federated identity provider to access Block Store.

How to add Block Store?

Step #1: Include Google’s Maven repository in both the buildscript and allprojects sections of your project-level build.gradle file:

buildscript {
    repositories {
        google()
    }
}

allprojects {
    repositories {
        google()
    }
}

Step #2: Add the Block Store API dependencies to your module’s app-level Gradle file, which is generally app/build.gradle:

dependencies {
  implementation 'com.google.android.gms:play-services-auth-blockstore:16.0.1'
}

Conclusion

When a user signs into your app, you may save the authentication token for that user to Block Store. This is accomplished by executing setBytes() on a StoreBytesData.Builder instance to save the user’s credentials to the source device. The token is encrypted and saved locally on the device once you save it with Block Store.

Later, when a user does a device-to-device restore flow on a new device, Google Play services first verify the user before retrieving your Block Store data. As part of the restore sequence, the user consented to recover your app data, therefore no further consents are necessary.


Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads