Node/quickstarts/firestore-sync-auth/README.md
This quickstart demonstrates using the Firebase SDK for Cloud Functions with Firestore with authentication context.
This sample app adds auth metadata to all documents written to a collection.
Before you can test the functions locally or deploy to a Firebase project,
you'll need to run npm install in the functions directory.
The Firebase Local Emulator Suite allows you to build and test apps on your local machine instead of deploying to a Firebase project.
Create a Firebase project in the Firebase Console
Wondering why this step is needed? Even though the emulator will run this sample on your local machine, it needs to interact with a Firebase project to retrieve some configuration values.
Run firebase emulators:start
Open the Emulator Suite UI
firebase emulators:start command for the URL
of the Emulator Suite UI. It defaults to
localhost:4000, but may be hosted on a different
port on your machine.Trigger the functions
firebase emulators:start command for the URL
of the http function "verifyComment". It will look similar to:
http://localhost:5001/MY_PROJECT/us-central1/verifyComment
MY_PROJECT will be replaced with your project IDcomments collection in Firestore in the emulator UI.View the effects of the functions in the Emulator Suite UI
In the "Logs" tab, you should see new logs indicating that the functions "verifyComment" and "makeuppercase" ran:
functions: Beginning execution of "verifyComment"
In the "Firestore" tab, you should see the document containing your original message updated to include auth context.
To deploy and test the sample:
firebase deploycomments collection in Firestore in the Firebase console.You should see the document containing your original message updated to include auth context.
We'd love that you contribute to the project. Before doing so please read our Contributor guide.
© Google, 2023. Licensed under an Apache-2 license.