TapanHP TapanHP - 1 year ago 73
Android Question

Firebase Login with twitter in android, how to add email.

I have implemented firebase auth with Gmail,Facebook, and Twitter and at very first I was not able to get email whenever I used Twitter the value returned always null, but after some digging I found solution and now I am getting email address of user by requesting it separately, but how can i add this email to firebase now?

protected void handleTwitterSession(TwitterSession session) {
Log.d(TAG, "handleTwitterSession:" + session);

AuthCredential credential = TwitterAuthProvider.getCredential(

.addOnCompleteListener(context, new OnCompleteListener<AuthResult>() {
public void onComplete(@NonNull Task<AuthResult> task) {
Log.e(TAG, "signInWithCredential:onComplete:" + task.isSuccessful());

Log.e(TAG, "user:" + task.getResult().getUser().getUid() + " : " + task.getResult().getUser().getDisplayName() + " : "
+ task.getResult().getUser().getEmail() + " : "+ task.getResult().getUser().getPhotoUrl());

// 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()) {
Log.e(TAG, "signInWithCredential", task.getException());

Above is the method I am using right now and there is no way to add email and on my firebase dashboard it shows empty value for email

empty value for mail

Answer Source

you can update current user's email address by calling user.updateEmail()

FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();

    .addOnCompleteListener(new OnCompleteListener<Void>() {
        public void onComplete(@NonNull Task<Void> task) {
            if (task.isSuccessful()) {
                Log.d(TAG, "User email address updated.");

Here is official document from firebase

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download