Skip to content
This repository has been archived by the owner on Sep 19, 2019. It is now read-only.

Transparent cross device sign in via SmartLock won't work #10

Closed
idanakav opened this issue Feb 2, 2017 · 4 comments
Closed

Transparent cross device sign in via SmartLock won't work #10

idanakav opened this issue Feb 2, 2017 · 4 comments

Comments

@idanakav
Copy link

idanakav commented Feb 2, 2017

Hi,
I'm trying to implement a transparent sign in to existing logged in users on new devices via SmartLock and Google Sign in.

The suggested flow is:

  1. User signing in to our app
  2. SmartLock saves the credential via (Auth.CredentialsApi.save)
  3. Install and launch the app on a new device with the same Google account
  4. SmartLock requests for existing credentials via (Auth.CredentialsApi.request)
  5. If credential found, preform a silent login via (Auth.GoogleSignInApi.silentSignIn)

Everything works great except for step 5, the silent login returns
Status{statusCode=SIGN_IN_REQUIRED, resolution=null}

I made sure and neither Auth.GoogleSignInApi.signOut / Auth.GoogleSignInApi.revokeAccess access were called in between.

I tried as well to use the regular login method,Auth.GoogleSignInApi.getSignInIntent but in that case the user sees the popup to select an account (even though there is only a single account) so that doesn't work as well.

So my question is why does the SIGN_IN_REQUIRED status is returned and how to resolve it?

According to the silentSignIn docs I see no reason why it shouldn't work:

If your user has never previously signed in to your app on the current device, we can still try to sign them in, without displaying user interface, if they have signed in on a different device.

We attempt to sign users in if:

There is one and only one matching account on the device that has previously signed in to your application, and
the user previously granted all of the scopes your app is requesting for this sign in.

Last note, I even tried to do test it on the same device by just clearing the app data after successful sign in and even then i'm seeing the same results.

Let me know if you need me to provide any other information
Thank you!

@samtstern
Copy link
Contributor

@idanakav thanks for the report. Can you show what you're using for your GoogleSignInOptions? Also what is your end goal of the sign in: do you want to get an ID Token? Email address? Something else?

@idanakav
Copy link
Author

idanakav commented Feb 3, 2017

re, thank you for the reply.

GoogleSignInOptions options = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN) .requestIdToken(...) .requestEmail() .build();

The end of the goal is to get the ID Token, display name and email.
Display name and email get be retrieved from the credential without any issue but credential.getIdTokens is always empty.

@samtstern
Copy link
Contributor

@idanakav are you calling setAccountName on the GoogleSignInOptions with the email retrieved from the Credential? See buildGoogleApiClient in the sample.

@idanakav
Copy link
Author

idanakav commented Feb 3, 2017

@samtstern added setAccountName and it fixed the issue, thank you!

@idanakav idanakav closed this as completed Feb 3, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants