我希望我首先使用FB登录的用户能够使用他/她的谷歌(同一封电子邮件)注销并再次登录 .

我该怎么办?我读了这个https://firebase.google.com/docs/auth/android/account-linking,但我不太明白 . 我认为链接是链接帐户,无论电子邮件 .

虽然我正在考虑的是firebase通过电子邮件识别用户,因此如果我使用相同的电子邮件成功登录和退出FB或Google,那么firebase应该知道它是同一个用户 .

在上面的帐户链接文档中,我们需要获取凭证/ tokenID并调用linkwithcredential,如下所示:

mAuth.getCurrentUser().linkWithCredential(credential)
    .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            Log.d(TAG, "linkWithCredential:onComplete:" + task.isSuccessful());

            // If sign in fails, display a message to the user. If sign in succeeds
            // the auth state listener will be notified and logic to handle the
            // signed in user can be handled in the listener.
            if (!task.isSuccessful()) {
                Toast.makeText(AnonymousAuthActivity.this, "Authentication failed.",
                        Toast.LENGTH_SHORT).show();
            }

            // ...
        }
    });

我的问题是:

  • 我称之为?每次登录时都需要调用它吗?

  • 那么每次登录时我是否还需要为每个提供商获取凭证?