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

后端 未结 2 907
野趣味
野趣味 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: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() {
                @Override
                public void onComplete(@NonNull Task 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.

提交回复
热议问题