3

I want to implement frictionless sign in process for my web app.

After some searching, I have found that there are two solutions available :

My question is, What is the difference between the two API's (if any) and what are the possible use cases for both of these.

From what I have understood, both allow us to save account related info. But the advantage with smart lock is, that saved credentials can be used in corresponding android apps as well.

Thanks !

Note: I intend to support login from multiple sources (google, facebook, linkedin etc.) , not just google.

Sachin
  • 3,350
  • 2
  • 17
  • 29

1 Answers1

1

TL;DR the one-tap sign-up / auto sign-in library includes Credential Management. You should probably just use the library: https://developers.google.com/identity/one-tap/web/get-started

Details

The JavaScript library supports account creation with Google Accounts (via a streamlined inline UX that can be shown on content pages instead user having to navigate to a traditional button-based UX and figure out which which button/option to pick and interact with pop-up/redirect)

And for returning users, the library allows you to programmatically retrieve on page load both tokens for existing one-tap / traditional Google Sign-In users as well as passwords via the Credential Management API in browsers that support it. You can do this with code such as the following:

const retrievePromise = googleyolo.retrieve({
  supportedAuthMethods: [
    "https://accounts.google.com",
    "googleyolo://id-and-password"
  ],
  supportedIdTokenProviders: [
    {
      uri: "https://accounts.google.com",
      clientId: "YOUR_GOOGLE_CLIENT_ID"
    }
  ]
});

retrievePromise.then((credential) => {
  if (credential.password) {
    // An ID (usually email address) and password credential was retrieved.
    // Sign in to your backend using the password.
    signInWithEmailAndPassword(credential.id, credential.password);
  } else {
    // A Google Account is retrieved. Since Google supports ID token responses,
    // you can use the token to sign in instead of initiating the Google sign-in
    // flow.
    useGoogleIdTokenForAuth(credential.idToken);
  }
}

See the documentation for details. The library does not currently support non-Google/password forms of identity, you'd have to implement sign-in flow with other mentioned identity providers SDKs yourself at the moment.

Also note that any sign-ins associated with a Google Account (OAuth token-based or stored and sync'ed password) will be available across Android and Chrome (and the rest of the for token-based accounts).

Please leave comments for any follow up questions.

Steven
  • 3,812
  • 23
  • 38
  • Hi @steven, thanks for response. But as I see, CM api also allows automated authentication from other federated login providers. But the problem is its only available from Chrome 60 onwards. The smart lock project (googleyolo), on the other hand, provides same thing across browsers. But the problem is its available only for google accounts. Am I correct ? – Sachin Nov 06 '17 at 07:38
  • The CM API does not support completely automated login to other providers ... it just remember which one was previously used (but doesn't return the needed token, you still need to the the other service's SDK). This complicates integration and hasn't been widely used, so we did not include it in the wrapper, but you could do both... – Steven Nov 06 '17 at 19:22
  • can you please check my question? https://stackoverflow.com/questions/63830860/app-and-website-saved-password-is-not-sync – Nirmal Sinh Revar Sep 17 '20 at 07:57