Search code examples
google-app-enginegoogle-cloud-platformgoogle-cloud-firestore

Using Firestore in a Google App Engine project


I want to access Firestore's real-time database inside of my Google App Engine project as an additional database.

What is the best way to write to Firestore from a Google App Engine backend? Would using the Firestore Rest API be decent? Or is there a better method?

How would authentication work between the two projects? Since as far as I understand a Google App Engine project and Firestore project are two separate things.


Solution

  • Yes, the best practice is to use the Firestore Rest API.

    Concerning the authentication, the app engine service has its default service account which you can find on the app engine page. Simply grant permissions to this service account on the project B to access & write firestore and the Lib SDK will smoothly handle everything!

    Which language are you using ? So I could edit my answer with a demo code

    Edit 1:

    You may misunderstand the concept of projects. A project is an envelope where you can use services. IN this example: you can have a single GCP project containing your firestore and your App Engine.

    Edit 2:

    As I thought, there's a code sample on the Google demo repo. Check this out ! https://github.com/GoogleCloudPlatform/java-docs-samples/tree/master/firestore