FirebaseUI authentication with Facebook not working

可紊 提交于 2019-12-19 05:08:33

问题


I am using FirebaseUI-Authentication. Signing in with an email or a Google account is successful, but sign in with Facebook doesn't work. onActivityResult() is not called after AuthUI activity was started and attempted to sign in with Facebook. After sign in attempt the app is stuck at the loading window. logcat outputs a FirebaseApp log:

Notifying background state change listeners.

On the Facebook app dashboard I set the Valid OAuth redirect URI, as the firebase guide stated, and I set the app public (does it matter if it is public or in development state?). In the Firebase console I enabled Facebook login and set the App ID and the App secret.

This is a video recording showing what happens after sign in with Facebook is clicked on the sign in activity.

Why isn't onActivityResult() called?

MainActivity:

/**
 * Use this method to start the FirebaseUI sign in activity.
 */
public void switchToSignIn() {
    this.activity.startActivityForResult(
            AuthUI.getInstance()
                    .createSignInIntentBuilder()
                    .setProviders(
                            AuthUI.EMAIL_PROVIDER,
                            AuthUI.GOOGLE_PROVIDER,
                            AuthUI.FACEBOOK_PROVIDER)
                    .build(), RC_SIGN_IN);
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == RC_SIGN_IN) {
        if (resultCode == this.activity.RESULT_OK) {
            // user is signed in!
            Log.d(Constants.TAG_LoginHandler, "Sign in result: RESULT_OK");
            logUserInfo();
            tryAccessMainFragment();
        } else {
            Log.d(Constants.TAG_LoginHandler, "Sign in result: RESULT_CANCELLED");
            // user is not signed in. Maybe just wait for the user to press
            // "sign in" again, or show a message
        }
    }
}

build.gradle:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.android.support:support-v4:23.4.0'
    compile 'com.android.support:design:23.4.0'
    compile 'com.firebaseui:firebase-ui:0.4.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'de.hdodenhof:circleimageview:1.3.0'
}

apply plugin: 'com.google.gms.google-services'

回答1:


If you are using FirebaseUI, you must put this exact string in strings.xml:

<string name="facebook_application_id" translatable="false">APPID</string>

The APPID can be found on your developers.facebook.com dashboard.

See firebaseui-auth readme

Also be sure to add your android key hash and OAuth firebase URL in the facebook app.




回答2:


Try updating to the new release of Google Play services where they have fixed up some Firebase Authentication related issues. (Though they have not specifically mentioned regarding Facebook login)

Google Play services updated to 9.0.2 The Google Play services version 9.0.2 release is now available. This release fixes a known issue with Firebase Authentication where the FirebaseAuthApi is not available on some devices.

https://developers.google.com/android/guides/releases



来源:https://stackoverflow.com/questions/37468316/firebaseui-authentication-with-facebook-not-working

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