FirebaseUI authentication with Facebook not working
Asked Answered
B

3

18

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'
Brooks answered 26/5, 2016 at 18:17 Comment(8)
Please make video as public.It is privateMacpherson
It is public now. thanks!Brooks
It is visible. ThanksMacpherson
See this. Its helps you.Macpherson
Didn't help... still having the same problem.Brooks
Please post your codePsephology
Code added. If any more code is needed, I will add.Brooks
github.com/firebase/quickstart-android/tree/master/auth Try this exampleJanot
O
9

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.

Opheliaophelie answered 15/7, 2016 at 21:39 Comment(1)
Hi, I have the same Facebook login problem in my app using FirebaseUI, If this is the solution, how to access to the strings.xml? Is there an easy way to locate this strings.xml file?Hamid
P
1

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

Psephology answered 4/6, 2016 at 7:36 Comment(1)
Unfortunately, it did not help.Brooks
P
1

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

Parol answered 11/5, 2020 at 9:38 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.