Firebaseui-android: Twitter auth, how to get email?

Created on 24 Nov 2016  路  10Comments  路  Source: firebase/FirebaseUI-Android

Greetings

It took me awhile but I can finally see what is in the new 1.0 release. So I handle to create the Twitter authentication and the user is correctly logged in. I was very surprised when in the firebase.google console the user have no email!

The first thing I did was to check it using:

String email = FirebaseAuth.getInstance().getCurrentUser().getEmail();
Toast.makeText(this, email, Toast.LENGTH_SHORT).show();

But there is no email. So I have being doing some search and found here some indications to get the email in web. However, in the Android documentation there is no email reference. What confuses me most is this StackOverflow question where is explained there is no way to get the email.

UPDATE: Another attempt to get more details was to send email verification, which didn't work with Twitter, cross check using email/password login.

Can we get the user email with Twitter login? Thanks in advanced.

Most helpful comment

@cutiko @juanlet I finally got around to testing it today and I can confirm that the email is received if you request it in the Twitter dashboard:
image

Also, what do you think of this update to the README?

All 10 comments

I just had the same problem. The email comes empty.....Maybe it's a privacy policy

I'm pretty sure this isn't related to Firebase-UI: https://apps.twitter.com lets you request the email permission in the permissions tab. I haven't tested it so I can't confirm that this works, sorry.

@cutiko @juanlet I finally got around to testing it today and I can confirm that the email is received if you request it in the Twitter dashboard:
image

Also, what do you think of this update to the README?

@cutiko @juanlet Just FYI, to get the email you'll need to reset the permissions used by your app by going to https://twitter.com/settings/applications and revoking it.

Just came to confirm this is working, thanks for the help

Hi, even when I chekc the "request email adress from user" box and reset the permisssion, I can't access the email from Twitter.
The FirebaseUI log display :
"com.firebase.uidemoE/TwitterProvider: Failure retrieving Twitter email. Your application may not have access to email addresses or the user may not have an email address. To request access, please visit https://support.twitter.com/forms/platform."
Any idea ?

@Toofoo "or the user may not have an email address". In Twitter the user have the choice to make the email private. I have being wonderimg what would happen in this scenario. Can you confirm this is the case?

Actually in the the twitter account it written that the e-mail adresse will not be displayed to public; but I don't see any option to change this. ???
(I checked the box : allow anybody to find me by email address

Just found that the email address is in result.user.providerData. (Or, was it exactly there?) Should not that be copied to result.user.email? (And in several other places too. o.O )

@lborgman is correct after I setup the request email address from users, it started showing up in the result.user.providerData (which is an array).
var email = result.user.providerData[0].email;
It looks hackish to read it from there and not directly from the user object where the email value is still null. An argument can be made that this email is an additional information from the provider, but truly all the params read via OAuth are from the provider, so I think framework should copy this value over to the user

Was this page helpful?
0 / 5 - 0 ratings