FIREBASE WARNING: Firebase Error. Please ensure that you spelled the name of your Firebase correctly - firebase

as you can see by the question, I am having trouble using Firebase in my app. I initialized the Firebase object and used the configuration from my Firebase account. Additionally, I have been able to authenticate users (I have a semi-functional login system going). So far, users can login to existing accounts and create new accounts. However, I am trying to store data with my user (during registration) by taking the uid from the user and using that in my Cloud Firestore. After they register, I am trying to store the other fields (firstName, lastName, school, etc.) into the Cloud Firestore under the uid.
this.props.firebase
.auth()
.createUserWithEmailAndPassword(this.state.email, this.state.password)
.then((auth) => {
this.props.firebase
.database()
.ref("users/" + auth.user.uid)
.set({data})...
It successfully creates the user but doesn't let me store the information in the Cloud Firestore and throws the error I displayed above. Can anyone help? Thank you!
Note: this.props.firebase is the reference to the firebase object instantiated with firebase.initializeApp()

Hahahaha, I suppose that I needed to actually create a real-time database in order for it to work. I had set up the Cloud Firestore while using the Realtime Database methods. Sorry to all for your troubles.

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.

Search and update document on Firebase Cloud function

I'm trying to integrate Stripe with Firebase as a backend.
I need to create stripe customer when new user signs up to my app.
for that I wrote 1 cloud function which will execute when new user created by Firebase Auth.
but in that function I'm getting Firebase auth's user.
from that I need to update my collection's document which is created for that user. (I'm storing Auth user's uid in my collection's document).
but somehow Firebase cloud function is not updating it.
Here is my Cloud function for same.
// When a user is created, register them with Stripe
exports.createStripeCustomer = functions.auth.user().onCreate(async (user) => {
const customer = await stripe.customers.create({email: user.email});
return admin.firestore().collection('fl_users').doc(user.uid).set({customer_id: customer.id});
});
I don't know what need to update how. Can you please help me to solve my problem?

Reference firestore database with firebase auth uID

Is there a way to reference Auth uID with my created users DB through firebase console? Or i need to do it through application by writing code?
Since my app doesn't have registration but only log in as a function, then i have already populated auth table, but i need to somehow reference each uID with user in DB.
One way that i thought about was that i would create new users DB field when someone logs in for the first time. That could be a workaround, but still.
Maybe someone has an idea or solution of what i should do to achieve a result for my problem?

Cloud Functions for Firebase: How to read/write to database as an existing user?

I like to use firebase functions to test firebase rules I defined.
I would like to read/write to realtime database as an existing user to test if the rules work as expected.
I read in getting started page, I can write to realtime database as admin as follow:
admin.database().ref('/messages').push({original: 'some text'});
How can I do the same as a user I have created in firebase instead of as admin?
I believe when you get the Delta Snapshot from the triggered event that the current state of that snapshot is tied to the user. Since the Firebase team is providing you with the server-less environment, they attach the admin as well since it's in a secure location.
So just grabbing the ref from the current snapshot, should give you the ability to test the database rules. Just to clarify, I am talking about the snapshot.ref, and not the snapshot.adminRef.
Here is the reference from their documentation:
Returns a Reference to the Database location where the triggering write occurred. This Reference has the same end-user permissions as the client that did the write. So, if an unauthenticated client did the write, this Reference is unauthenticated. If the client that did the write is authenticated as a certain Firebase Auth user, this Reference is authenticated as that same user.

Resources