Smart Lock on Android

HI guys, happened to see on Linkedin App, Smart lock dialog; Just wondered what is that?

I found to be a interesting feature particularly for app which want to provide a seamless integration of sign-in for the user who have already saved their credentials in Google chrome. its pretty straight forward to understand. Say in your linkedin app, just Login and chrome might prompt you to save password. On click of save password, chrome stores your credentials. Then you launch your Linked-in app, the credentials info from Chrome is shared to your mobile App and you got to signin automatically. seems magic; that is what smart lock does. Refer for more info

you would be wondering , sharing credentials…is it safe? Even I have no idea whether is safe proof. But I wondered that credentials object just gives password as String. Need to investigate.

screen-shot-2017-02-22-at-4-35-20-pm

To start with , you need to utilize Credentials API . All we need is to save the credentials and then read the credentials. pretty much sharing of credentials from Mobile to Web or vice versa.

Save:

Store user credentials with Auth.CredentialsApi.save():

Auth.CredentialsApi.save(mCredentialsClient, credential).setResultCallback(
  new ResultCallback() {
      @Override
      public void onResult(Status status) {
          if (status.isSuccess()) {
              // Credentials were saved
          } else {
              if (status.hasResolution()) {
                  // Try to resolve the save request. This will prompt the user if
                  // the credential is new.
                  try {
                      status.startResolutionForResult(this, RC_SAVE);
                  } catch (IntentSender.SendIntentException e) {
                      // Could not resolve the request
                  }
              }
          }
      }
  });

 

Read:

Retrieve stored credentials with Auth.CredentialsApi.request():

Auth.CredentialsApi.request(mCredentialsClient, mCredentialRequest).setResultCallback(
  new ResultCallback() {
      @Override
      public void onResult(CredentialRequestResult credentialRequestResult) {
          if (credentialRequestResult.getStatus().isSuccess()) {
              // Handle successful credential requests
          } else {
              // Handle unsuccessful and incomplete credential requests
          }
      }
  });

 

Seeing Netflix, Linked in and other major apps are moving towards it. Probably thats the future. Happy coding 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s