Problem statement
I have an existing backend, which does not use Firebase. This backend serves a web solution where users can sign in and order products. There's already an existing customer base.
Now, there's a new Android app which shall make use of Firebase Authentication with AuthUI for sign up / sign in of users.
Requirements
- I want to use Firebase's AuthUI in order to get a well tested workflow with high conversion rates.
- I do not want to rewrite the whole authentication implementation in the existing backend since unfortunately a lot tightly coupled integration solutions depend on it.
Case 1: Sign up via Google
This case seems to be the "easy" one:
If a user signs in with an email address that is not known to the existing backend, I can just tell the backend to register the auth token sent by Firebase and log in the user. If the backend already knows the token, the sign in can just be performed.
If the backend already knows a user with that email address, it can link the existing account to the token provided by the app (which gets it from Firebase).
That way, the app can always sign in the user using the Firebase token.
Case 2: Sign up via Email
For this case I've not come up with a solution:
- If a user signs in with an email address that is not known to the existing backend, I can just tell the backend to register the auth token sent by Firebase together with the email address, besides logging in the user. If the backend already knows the token, the sign in can just be performed.
But that way the user cannot sign in via the web solution with the same password. Afaik there is (probably for good reasons) no way to get the password the user supplied to AuthUI.
I'm looking for a way to allow sign in for the app and web with the same account data.
- If the backend already knows a user with that email address, it can link the existing account to the token provided by the app (which gets it from Firebase).
But this cannot work, since AuthUI needs a way to detect that the existing backend already knows the email address -- no sign up will then be required, but a sign in. Further more, AuthUI needs to validate the supplied sign in password against the existing backend.
I'm looking for a way to allow sign in with existing credentials from AuthUI.
Questions
As stated above, the problems to solve is to allow signing in via email / password from the app and web with the same account data, where these obstacles have to be overcome:
- The account data for new sign ups from within the app has to be propagated to the existing backend
- The account data for existing users has to be made accessible for AuthUI for account verification
Considerations
It seems that some kind of server-to-server communication is required to implement this. During my research I could not find any references on how to implement this. Thus I'm wondering if what I want to achieve is even possible or if I have to stay away from making use of AuthUI, meaning I have to implement an email signup / signin workflow by myself.