FirebaseUI Authentication with Facebook not logging in

淺唱寂寞╮ 提交于 2019-12-10 10:15:24

问题


I'm using FirebaseUI Auth in Android for user authentication.

Dependencies in my app build.gradle for Facebook Login:

compile 'com.google.firebase:firebase-auth:11.0.0'
compile 'com.firebaseui:firebase-ui-auth:2.0.0'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'

Classpath dependencies in my project build.gradle:

classpath 'com.google.gms:google-services:3.1.0'

My FirebaseUI Authentication Code in my Activity onCreate():

        final AuthUI.IdpConfig facebookIdp = new AuthUI.IdpConfig.Builder(AuthUI.FACEBOOK_PROVIDER)
                .setPermissions(Arrays.asList("email", "public_profile"))
                .build();

        mAuthChangeListener = new FirebaseAuth.AuthStateListener() {
            @Override
            public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) {
                FirebaseUser firebaseUser = firebaseAuth.getCurrentUser();

                if (firebaseUser != null) {
                    onSignedInInitialize(firebaseUser.getDisplayName());
                } else {
                    onSignedOutCleanUp();
                    startActivityForResult(
                            AuthUI.getInstance()
                                    .createSignInIntentBuilder()
                                    .setLogo(R.drawable.logo)
                                    .setTheme(R.style.LoginTheme)
                                    .setIsSmartLockEnabled(false)
                                    .setAvailableProviders(
                                            Arrays.asList(
                                                    new AuthUI.IdpConfig.Builder(AuthUI.GOOGLE_PROVIDER).build(),
                                                    facebookIdp,
                                                    new AuthUI.IdpConfig.Builder(AuthUI.EMAIL_PROVIDER).build()))
                                    .build(),
                            RC_SIGN_IN);
                }
            }
        };

My callback method in the same Activity:

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == RC_SIGN_IN) {
            if (resultCode == RESULT_OK) {
                Toast.makeText(MainActivity.this, "Signed In!", Toast.LENGTH_SHORT).show();
            } else if (resultCode == RESULT_CANCELED) {
                Toast.makeText(MainActivity.this, "Signing cancelled!", Toast.LENGTH_SHORT).show();
                finish();
            }
        }
    }

And my strings.xml:

<string name="facebook_app_id">xxxxxxxxxxxxxxx</string>
<string name="fb_login_protocol_scheme">fbxxxxxxxxxxxxxxx</string>

And of course I have added all the necessary details in Firebase Developer console and Facebook Developer console.

But when I am clicking on the Sign in with Facebook button, a loader with the facebook icon is showing up for few seconds and nothing is happening. It is still in the same screen.

My logcat details:

06-13 15:59:23.298 23599-26149/com.google.firebase.udacity.friendlychat D/FA: Logging event (FE): user_engagement(_e), Bundle[{firebase_event_origin(_o)=auto, engagement_time_msec(_et)=48262, firebase_screen_class(_sc)=AuthMethodPickerActivity, firebase_screen_id(_si)=-3048364835412835803}]
06-13 15:59:23.352 23599-26149/com.google.firebase.udacity.friendlychat D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=AuthMethodPickerActivity, firebase_previous_id(_pi)=-3048364835412835803, firebase_screen_class(_sc)=FacebookActivity, firebase_screen_id(_si)=-3048364835412835801}]
06-13 15:59:23.381 23599-26149/com.google.firebase.udacity.friendlychat D/FA: Connected to remote service
06-13 15:59:24.171 23599-23599/com.google.firebase.udacity.friendlychat E/FacebookProvider: Error logging in with Facebook. SERVER_ERROR: [code] 1675030 [message]: Error performing query. [extra]: Errors while executing operation "ProxyAuthAppLoginStartQuery": At Query.proxy_auth_app_login_start: Failed to resolve field.
06-13 15:59:24.194 23599-26149/com.google.firebase.udacity.friendlychat D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_previous_class(_pc)=FacebookActivity, firebase_previous_id(_pi)=-3048364835412835801, firebase_screen_class(_sc)=AuthMethodPickerActivity, firebase_screen_id(_si)=-3048364835412835803}]

Screenshots of my app:

Login Screen

On clicking sign in with Facebook, Loading and disappearing

Also the callback is not triggered.


Solution

(1) "user_friends" should be added in permissions. (2) Most importantly, <string name="facebook_application_id" translatable="false">APPID</string> should be the syntax and NOT <string name="facebook_app_id">APPID</string>. In developers.facebook.com, the variable name is given as "facebook_app_id" which is not working. The correct variable should be "facebook_application_id". These two changes solve the problem.

来源:https://stackoverflow.com/questions/44519255/firebaseui-authentication-with-facebook-not-logging-in

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