Android Question FirebaseAuth issue with Facebook login

Arthur Ávila

Member
Licensed User
At Firebase I can choose to allow one or multiple accounts with same email. As I understand from the Firebase Docs, if a user authenticates his account with a credential, he should strictly login by using the same credential if the credential is not linked with another one yet.

If I create an account by using Google sign in, and then (after sign out) try to login with Facebook credential by using the same email that is used for Google credential, I should see this error:

"An account already exists with the same email address but different sign-in credentials. Sign in using a provider associated with this email address."

With multiple accounts the problem is that I can't retrieve the user email if the user chose Google -> Facebook login, user.email is null.

There is some info about this issue on https://github.com/firebase/FirebaseUI-Android/issues/301 and https://groups.google.com/forum/#!searchin/firebase-talk/liu/firebase-talk/ms_NVQem_Cw/8g7BFk1IAAAJ

My doubt is what would be a good workaround to deal with this issue.

For one account per email I don't retrieve any error with the Google -> Facebook login. The only way I saw was in this post https://www.b4x.com/android/forum/threads/firebase-facebook-login.85642/
But, how can I get this error?

For multiple accounts I can't figure a way to get the user email.
 

Arthur Ávila

Member
Licensed User
Considering multiple accounts this code worked to get the Facebook email..

B4X:
Dim jo As JavaObject = Starter.auth.CurrentUser
Dim providerData As List = jo.RunMethod("getProviderData", Null)

'UserInfo
For Each item In providerData
    Dim jo2 As JavaObject = item
    Log("providerId : " & jo2.RunMethod("getProviderId", Null))
    Log("Email: " & jo2.RunMethod("getEmail", Null))
Next
 
Upvote 0
Top