Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

410
Vistas
How to let a signed in user create a document in firestore (SDK Web version 9 modular)

I'm trying to let a signed-in users create a document on the Firestore Database. For that I want to use the secureToken which gets created by Firebase Authentication after a user logs in with the email/password method.

In the Firebase Realtime Database for example, I can just make a post request with axios where I include the secureToken like this:

axios.post('https://project_name.europe-west1.firebasedatabase.app/posts.json?auth='
+ token, postData)

and in the Rules of the Realtime Database I have:

{
  "rules": {
    ".read": true,
    ".write": "auth != null"
  }
}

So that works fine so far.

But with the SDK 9 with the modular approach I don't know how to pass on the secureToken.

Here is the addDoc request:

const docRef = await addDoc(collection(db, 'posts'), { postData })

I was reading the cloud-documentation for hours, but couldn't find out how to proceed from here.

Only found this for adding data in general: https://firebase.google.com/docs/firestore/manage-data/add-data

and this for securely query data: https://firebase.google.com/docs/firestore/security/rules-query

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

If you are using Firebase SDK for authentication as well then you don't need to add any token. The SDK will check for auth state and do that for you.

const docRef = await addDoc(collection(db, 'posts'), { postData })

The above operation will add a document in posts collection if your Firestore security rules allow the current user to write there.


Are you using REST API for authentication as well? Then you you might have to use REST API for Firestore as well and pass the auth token yourself.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda