Using FirebaseAuth user meta-data vs managing them myself in Firestore

935 views
Skip to first unread message

flo.wa...@gmail.com

unread,
Oct 23, 2020, 11:35:52 AM10/23/20
to Firebase Google Group
I'm building a little chat app and I'm confused about how to work with the meta-data we can get from Firebase Auth (i.e. the displayName, profileImage etc.). We can only get this data for the currently logged in user, not query it and for example return a list of users with their profile information, right?
Then I am wondering why I need this functionality at all. Wouldn't it be more convenient to just save all the meta-data (display name, profile image url..) directly in my Firestore database?

Sam Stern

unread,
Oct 23, 2020, 11:39:48 AM10/23/20
to Firebase Google Group
Hello,

Yes it's almost always convenient to keep your primary user record in a database such as Firestore.  Firebase Auth cannot be queried or meaningfully extended.  The main use of those fields in Firebase Auth is to help you get the information that we retrieve from the primary identity provider, such as Google or Facebook.  It's also the only information that's easily accessible from Security Rules, so it's good to keep it up to date for that reason.

- Sam

On Fri, Oct 23, 2020 at 4:35 PM flo.wa...@gmail.com <flo.wa...@gmail.com> wrote:
I'm building a little chat app and I'm confused about how to work with the meta-data we can get from Firebase Auth (i.e. the displayName, profileImage etc.). We can only get this data for the currently logged in user, not query it and for example return a list of users with their profile information, right?
Then I am wondering why I need this functionality at all. Wouldn't it be more convenient to just save all the meta-data (display name, profile image url..) directly in my Firestore database?

--
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/dacacbe2-cc13-47fc-9646-3fdeff72b033n%40googlegroups.com.

flo.wa...@gmail.com

unread,
Oct 23, 2020, 10:25:28 PM10/23/20
to Firebase Google Group
Thank you!
So is it legitimate to only use the uid of Auth and store all the rest (username, profile image url, etc.) only in Firestore? Or should I keep them in sync with the values in Auth?

Sam Stern

unread,
Oct 26, 2020, 6:57:53 AM10/26/20
to Firebase Google Group
Yeah that's totally fine, as long as just having the "uid" is enough for you to write good security rules!

- Sam

flo.wa...@gmail.com

unread,
Oct 26, 2020, 11:30:32 AM10/26/20
to Firebase Google Group
Thank you very much!
Reply all
Reply to author
Forward
0 new messages