FirebaseUI-Android: [CRASH + DISCUSSION] Should we request Twitter email transparently?
While working on another PR, I came across this crash:
12-03 12:05:15.217 16688-16688/com.firebase.uidemo E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.firebase.uidemo, PID: 16688
java.lang.IllegalArgumentException: Given String is empty or null
at com.google.android.gms.common.internal.zzac.zzdv(Unknown Source)
at com.google.firebase.auth.FirebaseAuth.fetchProvidersForEmail(Unknown Source)
at com.firebase.ui.auth.ui.idp.CredentialSignInHandler.onComplete(CredentialSignInHandler.java:73)
at com.google.android.gms.tasks.zzc$1.run(Unknown Source)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6088)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
It’s caused by this line of code and occurs if a user has an existing account and there is a FirebaseAuthUserCollisionException
.
To solve this problem, there are two solutions:
- Check for a null email in
CredentialSignInHandler
and fail the sign in if the email is null. - Use
TwitterAuthClient#requestEmail
to show the request email activity.
I prefer solution 2 because we are being more transparent about requesting a user’s email, but it requires more steps and a Twitter user might not have an email: https://docs.fabric.io/android/twitter/log-in-with-twitter.html#request-user-email-address
@samtstern @amandle What should we do?
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 20 (8 by maintainers)
@cutiko You’re totally fine, that’s why FirebaseUI has public issues! 😄
@samtstern Hopefully my comment and the above will help you understand why we need the email. Adding the null check in
CredentialSignInHandler
fixes the crash for Twitter users without an email, but we still need the email before the user is signed to perform linking for Twitter users with an email.@cutiko Yes, the plan is to force you guys to request the email permission (or at least if you don’t neither account linking nor Smart Lock will work).
The fix should be out by FirebaseUI v1.1.0! 🎉