FirebaseUI Auth library: Google sign in fails with: W/AuthMethodPicker: Firebase login unsuccessful

孤街醉人 提交于 2019-12-06 06:25:00

问题


Using the available online documentation and this video: https://www.youtube.com/watch?v=0ucjYG_JrEE, I'm trying to start apply the new UI Auth library. Mail sign in works great, the Google sign in not: it gives a warning and the UI keeps showing the "Loading..." dialog.

final FirebaseAuth auth = FirebaseAuth.getInstance();
        auth.addAuthStateListener(new FirebaseAuth.AuthStateListener() {
            @Override
            public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                FirebaseUser usr = firebaseAuth.getCurrentUser();

                if (usr != null){
                    Log.d( TAG, "User signed in correctly: " + usr );
                    auth.removeAuthStateListener( this );
                } else {
                    //signed out
                    Log.d( TAG, "User is not signed in" );
                    auth.removeAuthStateListener( this );

                    startActivityForResult( AuthUI.getInstance().createSignInIntentBuilder()
                            .setTheme( R.style.AppBaseTheme )
                            .setProviders(
                                    AuthUI.EMAIL_PROVIDER,
                                    AuthUI.GOOGLE_PROVIDER
                            ).build(), RC_SIGN_IN );


                }
            }
        });

Output:

05-21 13:49:33.595 25005-25005/com.xxx.xxx W/AuthMethodPicker: Firebase login unsuccessful

More log output would be helpful. Note that this only happen on a imported Firebase project, not on a newly created Firebase project.

UPDATE: just discovered this in the console:

05-22 14:29:58.178 10075-10310/? V/BaseAuthAsyncOperation: access token request successful
05-22 14:29:58.179 10075-10310/? V/AuthAccountOperation: id token is requested.
05-22 14:29:58.758 10075-10310/? E/TokenRequestor: You have wrong OAuth2 related configurations, please check. Detailed error: INVALID_AUDIENCE
05-22 14:29:58.758 10075-10310/? D/AuthAccountOperation: id token request failed.

回答1:


Just found the cause of this issue: my app used an unexpected (wrong) debug.keystore for signing of the debug APK... after pointing to the correct debug.keystore within my build everything works as expected!

(Answer found thank to this thread: Android Studio - debug keystore)

P.s. Thanks to the Google/Firebase team for delivering the UI Auth solution: this is a great improvement!




回答2:


For anyone getting this on a release build. Make sure you have a correct SHA1 fingerprint in your Firebase project settings.

Note that debug and release keystores have different fingerprints.

Here's how you get the correct fingerprint: https://developers.google.com/android/guides/client-auth



来源:https://stackoverflow.com/questions/37362620/firebaseui-auth-library-google-sign-in-fails-with-w-authmethodpicker-firebase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!