使用Facebook的FirebaseUI身份验证无效

时间:2016-05-26 18:17:46

标签: android firebase facebook-authentication firebase-authentication firebaseui

我正在使用 FirebaseUI-Authentication 。使用电子邮件或Google帐户登录是成功的,但使用 Facebook 登录无效。 AuthUI 活动启动并尝试使用Facebook登录后,不会调用onActivityResult()。登录后尝试将应用程序停留在加载窗口。 logcat输出FirebaseApp日志:

  

通知背景状态更改侦听器。

在Facebook应用程序仪表板上,我设置了有效的OAuth重定向URI ,正如firebase指南所述,我将应用程序公开(如果它是公共的还是处于开发状态,这是否重要?)。 在 Firebase控制台中,我启用了Facebook登录并设置了 App ID App secret

This是一段录像,显示点击登录活动后登录Facebook后发生的情况。

为什么onActivityResult()没有被调用?

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'

3 个答案:

答案 0 :(得分:8)

如果您使用的是FirebaseUI,则必须将此确切字符串放在strings.xml中:

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

可以在 developers.facebook.com信息中心上找到 APPID

请参阅firebaseui-auth readme

还要确保在Facebook应用中添加您的Android密钥哈希和OAuth firebase URL。

答案 1 :(得分:1)

尝试更新到新版本的Google Play服务,他们已修复了一些与Firebase身份验证相关的问题。 (虽然他们没有特别提到Facebook登录)

Google Play服务已更新至9.0.2 Google Play服务版本9.0.2版现已推出。此版本修复了Firebase身份验证的已知问题,其中FirebaseAuthApi在某些设备上不可用。

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

答案 2 :(得分:1)

这发生在我身上,也可能发生在某人身上,我忘记在Firebase控制台中启用Facebook身份验证! 转到firebase conosle并选择您的应用程序,然后转到身份验证->登录方法并启用facebook,并从您的facebook deevloper项目中添加应用程序ID和密钥