Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FirebaseUI authentication with Facebook not working

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'
like image 895
Amitai Fensterheim Avatar asked May 26 '16 18:05

Amitai Fensterheim


3 Answers

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.

like image 165
jacktrades Avatar answered Nov 05 '22 13:11

jacktrades


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

like image 32
Chebyr Avatar answered Nov 05 '22 14:11

Chebyr


this happened to me and might happened to some one , I forgot to enable facebook authentication in firebase console! goto firebase conosle and select your app then go to authentication->sign-in methods and enable facebook and add the app id and secret key from your facebook deevloper project

like image 27
Mohammed Fathi Avatar answered Nov 05 '22 15:11

Mohammed Fathi