firebase / FirebaseUI-Android

Optimized UI components for Firebase
https://firebaseopensource.com/projects/firebase/firebaseui-android/
Apache License 2.0
4.63k stars 1.83k forks source link

Silent signin doesn't work #1553

Closed trogalko closed 5 years ago

trogalko commented 5 years ago

Step 2: Describe your environment

Step 3: Describe the problem:

I Followed the example in the app folder in this repository for firebaseui-auth silent sign in,

  1. Internet connection is OK, and internet permission is added to manifest file. Furthermore, I'm able to show query from firestore db to recyclerview
  2. This is code for silent signin click, exactly the same with example code
   @OnClick(R.id.sign_in_silent)
    public void silentSignIn() {
        List<AuthUI.IdpConfig> providers = getSelectedProviders();
        AuthUI.getInstance().silentSignIn(this, providers)
                .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                    @Override
                    public void onComplete(@NonNull Task<AuthResult> task) {
                        if (task.isSuccessful()) {
                            startSignedInActivity(null);
                        } else {
                            showSnackbar(R.string.sign_in_failed);
                        }
                    }
                });
    }
  1. This sign in click button code with hardcoded modifications
    @OnClick(R.id.sign_in)
    public void signIn() {
        AuthUI.SignInIntentBuilder builder =  AuthUI.getInstance().createSignInIntentBuilder()
                .setTheme(getSelectedTheme())
                .setLogo(getSelectedLogo())
                .setAvailableProviders(getSelectedProviders())
                .setIsSmartLockEnabled(true);
        //.setIsSmartLockEnabled(mEnableCredentialSelector.isChecked(),
        //mEnableHintSelector.isChecked());

        if (getSelectedTosUrl() != null && getSelectedPrivacyPolicyUrl() != null) {
            builder.setTosAndPrivacyPolicyUrls(
                    getSelectedTosUrl(),
                    getSelectedPrivacyPolicyUrl());
        }

        startActivityForResult(builder.build(), RC_SIGN_IN);
    }

Observed Results:

100% failed, with smart lock enabled, and I have signed in before.

Expected Results:

The silent sign click button should signed me in

samtstern commented 5 years ago

@trogalko silent sign in only works if we can find a way to sign you in without UI. That means either a saved account in SmartLock (and only one option there) or a saved Google Sign In account. Are those conditions met in your case?

trogalko commented 5 years ago

Yes, I have enabled Smart Lock for Password, and Auto sign-in, the application also not in the Never save list app.

samtstern commented 5 years ago

If you do a "regular" sign in (not silent) are you signed in automatically with smart lock?

samtstern commented 5 years ago

@trogalko are you still having this issue? If so see my last question.

trogalko commented 5 years ago

If you do a "regular" sign in (not silent) are you signed in automatically with smart lock?

Yes, device with both single and multiple google account, I could choose which account to sign in (being prompted to choose user account to sign in without to enter password).

trogalko commented 5 years ago

@trogalko are you still having this issue? If so see my last question. I'll try to combine FirebaseUI Auth with SharedPreferences. Btw, here is the my app. link on Play Store : https://play.google.com/store/apps/details?id=com.rscmkencana.rscmkencanamobile&hl=en

samtstern commented 5 years ago

@trogalko I think this is working as intended. In a situation where you are "being prompted to choose user account to sign in without to enter password" that means we can't do silent sign in. Silent sign in only works when there is exactly one account to choose from and the user has already granted enough permissions for the sign in to proceed without any UI.

That means either a single saved account in SmartLock (so you get the blue bar) or a single Google account where the current device/app has already been authorized.

Thanks for providing all the information, closing this bug as WAI for now. Let me know if I've gotten it wrong!