Firebase: Can I use Facebook's new Account Kit to authenticate app users?

后端 未结 2 905
野趣味
野趣味 2021-02-01 11:05

Facebook just introduced Account Kit at F8 2016.

It enables app users to log in using their phone number or email address.

I already tried to use it\'s returned

相关标签:
2条回答
  • 2021-02-01 11:35

    I got the following answer in the Firebase Google Group:

    Yeah, after discussing with another Firebase engineer, I'm pretty sure Firebase Authentication does not actually support Account Kit. Sorry. We have no plans to support it in the works, but will revisit if we get enough people asking for it.

    0 讨论(0)
  • 2021-02-01 11:42

    Yes, it's possible using Firebase Custom Authentication.

    You need to setup an authentication server which can create Firebase custom tokens, using the accountkit user id or phone number as the uid.

    Once you receive the custom token from the authentication server, you then use it to sign into firebase like this:

    mAuth.signInWithCustomToken(mCustomToken)
            .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                @Override
                public void onComplete(@NonNull Task<AuthResult> task) {
                    Log.d(TAG, "signInWithCustomToken:onComplete:" + task.isSuccessful());
                    if (!task.isSuccessful()) {
                        Log.w(TAG, "signInWithCustomToken", task.getException());
                        Toast.makeText(CustomAuthActivity.this, "Authentication failed.",
                                Toast.LENGTH_SHORT).show();
                    }
                }
            });
    

    This blog post has a detailed step-by-step guide on how to implement it.

    0 讨论(0)
提交回复
热议问题