0

I have a Login activity with email and passwords fields, when you fill those fields with credentials of an account created using FirebaseAuth createUserWithEmailAndPassword() method no problem at all.

But when you fill the email and pass fields with credentials of an account created using GoogleSignIn button it gives me this error: The password is invalid or the user does not have a password.

I have tried to send and accept a verification email when a user sets up his account because I thought it had something to do with non-verificated emails, but I still get the error.

- SUMMARY -

So the thing is I want to have 2 ways of registering users, one by filling the email & pass fields and, the other through GoogleSignIn. So my problem is, how do I design a "system" to log in those accounts? I mean, I can log in user who have filled the email & pass fields, but I can not log in users who had use GoogleSignIn.

At this point, it's clear that I'm not understanding well how this process works. Can anyone guide me a little bit about it? Thanks in advance :)

- EDIT -

I have been trying a workaround with giving the user a Google SignIn button in the same Login Activity but I'm also facing a problem which I have already made another StackOverflow post

INDRAJITH EKANAYAKE
  • 3,894
  • 11
  • 41
  • 63
SoleR
  • 13
  • 1
  • 5
  • Signing in a user to Firebase Authentication with a Google account does not give their Firebase Authentication account a password. That would actually pretty insecure as Firebase would have to get that password information from the Google account, which is thankfully impossible. I'm not sure I understand what you're trying to accomplish though, and it seems a bit of a [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). Can you describe what your goal is and show the code of how you're trying to reach that goal? – Frank van Puffelen Apr 27 '19 at 16:01
  • Thanks for your aclaration Frank! So the thing is I want to have 2 ways of registering users, one by filling the email & pass fields and, the other through GoogleSignIn. So my problem is, how do I design a "system" to login those accounts? I mean, I can login user who have filled the email & pass fields, but I can not Login users who had use GoogleSignIn. – SoleR Apr 27 '19 at 16:13
  • You can link the providers that you want the user to sign in with. See https://firebase.google.com/docs/auth/android/account-linking – Frank van Puffelen Apr 27 '19 at 16:34
  • @FrankvanPuffelen But after doing a Google SignUp how can I link a email/pass provider if to do it so I have to `EmailAuthProvider.getCredential(email, password)` and I dont know the password of the user that have already SignUp using Google OAuth ? – SoleR Apr 27 '19 at 17:34
  • @SoleR When the user has signed up via Google, you have to ask him if they want to add an email/password auth to their existing Google account. Simply call `AuthCredential credential = EmailAuthProvider.getCredential(email, password);` passing user's credentials as parameters (from a form...) and then link it : `mAuth.getCurrentUser().linkWithCredential(credential)` User has to enter his own credentials via a form, you shouldn't know their Google password – MichelDelpech Apr 27 '19 at 20:05
  • @Firebaser thanks for your answer but I don't get that, what's the point of giving the user the possibility to user Google OAuth if after the user have to put an email&pass that he have to remember in order to SignIn? I'm the only one who thinks that's is weird? But maybe I did not get what you told me right, sorry – SoleR Apr 28 '19 at 10:14
  • As far as I know, you can't use the Google credentials in your email/pass form, because credentials are binded to the provider itself. If you want to share a same user profile between multiple providers, you have to do accounts linking as explained above. In short, you can't share credentials between auth providers, but you can associate multiple providers to a user UID. – MichelDelpech Apr 28 '19 at 11:12

0 Answers0