如何从FirebaseUI身份验证获取Twitter配置文件信息

时间:2019-05-13 16:21:33

标签: android firebase-authentication twitter-oauth firebaseui

目前,我可以获取DisplayNameEmailuid等信息,以及如何获取诸如@myname和其他类似description之类的句柄名称。

startActivityForResult:

List<AuthUI.IdpConfig> providers = Arrays.asList(
                    new AuthUI.IdpConfig.TwitterBuilder().build()


            );

            startActivityForResult(

                    AuthUI.getInstance()
                            .createSignInIntentBuilder()
                            .setAvailableProviders(providers)
                            .build(),1
            );

onActivityResult:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode == 1) {
            IdpResponse response = IdpResponse.fromResultIntent(data);

            if (resultCode == RESULT_OK) {

                if (response.isNewUser())
                {
                   String username = FirebaseAuth.getInstance().getCurrentUser().getDisplayName();
                   String email = FirebaseAuth.getInstance().getCurrentUser().getEmail();
                }

                Intent timelineIntent = new Intent(this, TimelineActivity.class);

                startActivity(timelineIntent);
                finish();

            } else {

                if (response.getError().getErrorCode() == ErrorCodes.PROVIDER_ERROR)
                    finish();

                if (response == null)
                    finish();
            }
        }
    }

0 个答案:

没有答案