Firebase Authentication with my own backend -- Workflow

2,962 views
Skip to first unread message

Anthony Li

unread,
Jun 20, 2023, 1:36:40 AM6/20/23
to Firebase Google Group
Hey Everyone,

I have implemented Firebase Authentication in my frontend, but am only using it for authentication. I am creating users and storing data in my own separate backend. This results in creating two separate users -- one in my Firebase Auth project and one in my backend. This workflow seems very awkward since I am always maintaining two users, and I imagine that I am introducing security risks if say I have to change a password somewhere down the line. My question is if there is a better workflow for this, as I can't seem to find anything in the documentation around maintaining both a user in the Firebase Auth project and in my backend. 

This is what my workflow ends up being:
  1. User inputs email, password, where they live, other non-Firebase-related info
  2. Create user in backend
  3. Create user with same email and password in Firebase Auth, which creates a new user in my Firebase project.

Thank you for reading, and any feedback is much appreciated!

Anthony

Rachel Myers

unread,
Jun 20, 2023, 12:07:40 PM6/20/23
to fireba...@googlegroups.com
If you're already storing user data on your own, I'd suggest authenticating people on your server and then using Custom Auth to exchange your auth token for a Firebase token you can use for other Firebase projects. https://firebase.google.com/docs/auth/web/custom-auth

Best,
Rachel

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/ab27c1b8-d547-4c83-ae31-1eed3bdf50aen%40googlegroups.com.

Anthony Li

unread,
Jun 20, 2023, 5:15:13 PM6/20/23
to Firebase Google Group
That makes sense! I have read this page multiple times, but I must been out of it from reading so many other pages of documentation. Thank you so much for your help!

Anthony

Francesco Virga

unread,
Feb 2, 2024, 10:30:19 AM2/2/24
to Firebase Google Group
Hi there, wondering if there's a way to do this with oauth as well? Id like to authenticate the user using Google Sign in on my frontend without actually creating them in Firebase. Then send some credential to the backend, which the backend can validate, and finally create the user in both my DB and in Firebase. 

This handles a case where the user is created in Firebase but not the backend DB (eg firebase auth succeeds, but backend is unreachable so signup is not completed). 

Seems like the custom token is ideal for email/pwd sign in, but i dont think it handles oauth.

Thanks,
Francesco
Reply all
Reply to author
Forward
0 new messages