1

I'm implementing Google Smart Lock into my app. I've got it logging the user in automatically with a single account and it works well.

However, once I add a second account to the mix it always shows the resolution dialog to pick which account I want. This continues to show even after I have selected and account and restarted the app.

This dialog shouldn't show anymore once I have selected the account I want smart lock to use, so what are some possible reasons for it still showing?

-Thank you

Elforama
  • 512
  • 1
  • 4
  • 16

2 Answers2

3

I work on the Smart Lock team at Google, hopefully this answers your question:

  • as you note, if the CredentialsApi.request() API method is called and there are multiple saved accounts for the app, stored in either one or multiple Google Accounts on the device (or auto sign-in has been disabled by the user for one of their accounts or by the developer by calling CredentialsApi.disableAutoSignIn()) then the API will call back with a CredentialRequestResult with getStatusCode() of RESOLUTION_REQUIRED, meaning that UI must be shown for the user to pick a credential to continue. startResolutionForResult() will show the dialog, as described in the API overview.

  • once the app has a credential, either from auto sign-in or after the user has selected one from the dialog, most apps will use this credential to sign the user in to a backend service and establish a session with a cookie or token for the app and manage this independent of the Smart Lock API. Thus, most apps won't call the API again after the user has signed in and a current session exists, hence the dialog won't be shown again after the initial sign-in.

  • when the user signs out, calling CredentialsApi.disableAutoSignIn() will prevent the user from being automatically signed back in when the authentication activity is started again, and the disabled state is automatically managed and cleared when the user selects an entry from the credential picker UI or a successful CredentialsApi.save() call is made, and at this point, a user session is established and there is no need to call the API again until a sign-out event.

I think the confusion in this question stems from calling the API after the user has signed in and they might already have an active session. Was that your intent? If you need to manage credentials of the app on the device after a password has been retrieved or input by the user, you can use the Account Manager on Android, which is independent of any Google accounts or APIs (whereas Smart Lock is geared toward saving sign-in info in the cloud for use across platforms on new or separate devices to bootstrap the auth process).

In the future, we are considering remembering a user preference if multiple accounts are stored and the same one is always picked, thereby allowing automatic sign-in, but right now, user action is always required when there are multiple saved accounts available.

Do leave a comment with any questions or feedback if you need more info or clarification or if this doesn't answer your question!

Steven
  • 3,812
  • 23
  • 38
  • Thanks Steven, this is what I was looking for. The app I'm working on requires that the user log back in each time the app is restarted so I want it to be done automatically. I am currently retrieving credentials every time the app is restarted and I am using the credentials API to get stored login info. It seems in my case the account selection dialog will always have to be shown as long as there is more than one account. I do hope you're able to add that extra feature in the future. Thanks for the help! – Elforama Dec 31 '15 at 16:14
  • Great, do you have a pointer to your app, is it available on the Play Store? I'll have our UX / eng team take a look at this use case and see if we can make a recommendation or consider adjustments to the API. – Steven Dec 31 '15 at 17:04
  • That would be a great help, here is the G+ alpha community. Please join this to download the latest version with the SmartLock feature. https://plus.google.com/communities/109600259045316723754 – Elforama Dec 31 '15 at 19:16
  • Thanks, actually turns out I'm already in the group and have tried the app ;) ... sent some feedback I had to the alpha feedback email address ... will give this particular problem some more thought and let you know. – Steven Dec 31 '15 at 19:48
0

When you have multiple account, you will always show this resolution dialog. Look this : https://developers.google.com/identity/smartlock-passwords/android/images/smartlock-passwords-flow.png

from : https://developers.google.com/identity/smartlock-passwords/android/overview

Pauland
  • 1,974
  • 16
  • 25
  • This seems to defeat the purpose of the auto sign-in feature. A little deeper in the docs it mentions that if a user signs out, to disable auto sign-on in order to let the user log in with a different account. The moment they log in with a different account the auto sign-in shouldn't be disabled, it should just start signing them into their new account. Perhaps I am missing something here. – Elforama Dec 30 '15 at 20:34
  • I think 90% of users will have one account. In my case, with multiple account, i always see this dialog. When i have one account >> auto-login If i logout >> dialog (even if i have one account) – Pauland Dec 31 '15 at 09:52