与Facebook的FirebaseUI身份验证不起作用 [英] FirebaseUI authentication with Facebook not working
问题描述
我正在使用 FirebaseUI-Authentication 。使用电子邮件或Google帐户登录是成功的,但是使用 Facebook 登录不起作用。在 AuthUI 活动已启动并尝试使用Facebook登录后, c $ c> onActivityResult()不会被调用。登录尝试后,应用程序卡在加载窗口。 logcat输出FirebaseApp日志:
$ b
通知后台状态更改侦听器。
在Facebook应用程序面板中,我设置了有效的OAuth重定向URI ,如firebase指南所述,并且将应用程序设为公开(如果它是公开的或正在开发中州?)。
在 Firebase控制台中,我启用了Facebook登录并设置了应用ID 和应用密码。 b
这是一个视频录像,显示在点击Facebook后点击
为什么不是 onActivityResult()
被调用?
MainActivity:
$ b
/ **
*方法来启动FirebaseUI登录活动。
* /
public void switchToSignIn(){
this.activity.startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setProviders
AuthUI.EMAIL_PROVIDER,
AuthUI.GOOGLE_PROVIDER,
AuthUI.FACEBOOK_PROVIDER)
.build(),RC_SIGN_IN);
$ b $ @覆盖
保护无效onActivityResult(int requestCode,int resultCode,Intent数据){
if(requestCode == RC_SIGN_IN){
if (resultCode == this.activity.RESULT_OK){
//用户登录!
Log.d(Constants.TAG_LoginHandler,登录结果:RESULT_OK);
logUserInfo();
tryAccessMainFragment();
} else {
Log.d(Constants.TAG_LoginHandler,Sign in result:RESULT_CANCELLED);
//用户未登录。也许只是等待用户再次按
//登录,或者显示一条消息
}
}
}
build.gradle:
dependencies {
如果您使用的是FirebaseUI,则必须将这个确切的字符串放在strings.xml中:
编译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'
编译'de.hdodenhof:circleimageview:1.3.0'
}
apply plugin:'com.google.gms.google-services'
b
$ b< string name =fac ebook_application_idtranslatable =false> APPID< / string>
APPID 可以在 developers.facebook上找到。 com dashboard 。
另外,请务必在facebook应用程序中添加您的android密钥哈希值和OAuth firebase网址。 / p>
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'
解决方案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.
Also be sure to add your android key hash and OAuth firebase URL in the facebook app.
这篇关于与Facebook的FirebaseUI身份验证不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!