小编Muh*_*han的帖子

使用Facebook登录集成的Firebase Auth用户的空电子邮件字段(Firebase 3.0)

我已成功部署了https://firebase.google.com/docs/auth/android/facebook-login中的教程代码,以便将Firebase身份验证登录与Facebook集成.用户已在Firebase Auth控制台中成功创建.

但是,我注意到用户对象中的电子邮件字段为空( - ).奇怪的是,我使用获取的令牌使用GraphRequest直接从提供者结果对象中成功检索了电子邮件信息.

根据我阅读的文档(https://firebase.google.com/docs/reference/android/com/google/firebase/auth/FirebaseUser.html#getEmail()),应从登录提供商填充电子邮件字段.

一些额外的奇怪行为:

  1. 成功登录后,将调用onAuthStateChanged两次.firebaseAuth.getCurrentUser().getProviderId()的值在两种情况下都是Firebase
  2. 我尝试从FirebaseUser对象user.getProviderData()列出提供程序.我有两个提供商:firebase和facebook.com
  3. 当我尝试使用FirebaseUser.updateEmail(event.getEmail())更新电子邮件时,我收到此错误:发生了内部错误.[EMAIL_EXISTS]

有什么我想念或做的我做错了吗?

这是我的代码:

public class LoginActivity extends AppCompatActivity {
    private static final String TAG = "LOGIN_ACTIVITY";
    private static final int RC_SIGN_IN = 777;
    private EventBus eventBus;
    private SweetAlertDialog pDialog;

    private FirebaseAuth mAuth;
    private FirebaseAuth.AuthStateListener mAuthListener;
    private CallbackManager mCallbackManager;
    private ImageView mPasswordVisibilityView;
    private TextView txtPassword;
    private boolean justEnteredAuthStateChanged = false;
    private GoogleApiClient mGoogleApiClient;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        FacebookSdk.sdkInitialize(getApplicationContext());

        setContentView(R.layout.login);

        // Firebase
        mAuth = FirebaseAuth.getInstance();

        mAuthListener …
Run Code Online (Sandbox Code Playgroud)

android facebook-authentication firebase firebase-authentication

20
推荐指数
4
解决办法
1万
查看次数