Storing Firebase UID in an external database - firebase

I am using firebase auth for a project. Since we don't want to be in charge of handling passwords, and eventually want to add social login we're going to use FireBase.
We have an .NET WEB API set up right now with its own database. In this database some tables have reference to user's. Example: Order table would need a customer id.
Since we're only using Firebase Auth we're thinking about storing some user data in our database. Specifically:
FirstName | LastName | Role.
Would it be okay to store the Firebase UID in our tables as well, or is the a different parameter we should be using?

Yes, what you want is a unique identifier for each user and sounds like Firebase's auth UID is unique across the same project. Based on Firebase's document:
getUid() Returns a string used to uniquely identify your user in
your Firebase project's user database.
Also check this answer:
Is Firebase UID unique across multiple apps?

Yes, it's very common to store Firebase Auth UIDs in a database to store per-user information.

Related

Read Firebase authentication records with R

Using R, I am trying to read the Firebase authentication records created by users for our project, projectID. To be clear, I do not wish to read, nor can I read, the user pswd, just the Firebase authentication ID, known as the User UID.
Firebase creates a unique UID when a user record is created. This in turn populates a collection, call it collectionID, where the key to collectionID is the Firebase authentication User UID. Other information about the user's use of our application is stored within this collection.
I can read the collectionID using the Firestore library created by Luis Rodriguez - github("luizmirodriguez/FireStore") - as follows:
fireStore.download(projectID,collectionID,auth$credentials$access_token).
I cannot download the authentication records shown in Firebase Console with R today. Does anyone know how to do this?
It may be as simple as knowing the name of the collection (authentication, authentication/users, authentication/users_uid all produce errors).
Any help appreciated

Is it possible for Firestore to generate the same uid when registering a user?

I have my backend hosted in firebase. Whenever a new user registers I create a new account in my firestore collection. Each user will be identified by a unique uid generated by firebase. Is it possible with enough users to generate the same uid and hence write over another user's data when registering? Or does firestore have any built-in measures to prevent this from happening? Thanks in advance.
Firebase Auth guarantees that each user will have a truly unique ID within your project. There is nothing you have to do. Just accept the UID it generates.

Firebase users and information

How do I store profile information for users in App Inventor using Firebase (e.g:Full name, age, some answers to some question that need to be displayed on his profile)?
I tried the Auth extension, but it doesn't provide too many options. Do I make use of user's UID?
Using their user ID, save their data in Cloud Firestore or Realtime Database. Then you can retrieve and store any data you want.

Firebase auth, is the user uid security sensitive?

I was wondering if getAuth().uid is sensitive/private in anyway? I am planning to use it on a user post something like: post.created_by: getAuth().uid. This makes writing rules/logic a lot easier.
The other way is to use the push id when the user is added to the database, which I'm trying to avoid.
No its safe to use the uid and recommended, firebase uses auth to authenticate the user and the assign the uid to identify the user across firebase.
You will be using uid in your security rules and as well as to identify user info in your db records.
Manually creating another id will render the efficiency of firebase useless.

Cloud Firestore associate logged user with collection

I'd like to know the best approach/pattern to implement for the following use case.
I'm using Firebase Auth to sign up/in users and it's working fine.
As soon as the auth is performed I need to fetch from a Cloud Firestore collection, say user_profile, the data related to the logged user.
The problem is that the collection has its id which is not related to the user, since it's automatically generated by Firestore. So I don't know what to put in <user>
db.collection("user_profile").doc(<user>).get()
A possible solution I came up with is to store the user id inside user_profile and then query the whole collection like this
db.collection("user_profile").where("id", "==", id_from_auth).get()
Making the id field index of the collection.
Is this a good approach?
Is there a better/smarter/automatic way of doing this?
It's customary to store per-user data in a document keyed by the uid of the user authenticated by Firebase Authentication.

Resources