willhlaw / node-firestore-backup-restore

Google Firebase Firestore backup and restore tool
91 stars 24 forks source link

Update tool to use gcloud auth instead of requiring credentials.json #6

Open willhlaw opened 6 years ago

willhlaw commented 6 years ago

Right now, this tool requires a service account credentials.json file to be specified to be able to access Google Firestore rules API. I think we should update it to allow gcloud auth instead or as an alternative.

However, I have verified it works if we do the following:

  1. npm install -g @google-cloud/cloud-sdk
  2. open new terminal so gcloud is on the PATH
  3. run gcloud auth application-default login and gcloud config set project [PROJECT_NAME]

After that, we do not need credentials.json if we update firestore-backup-restore to initialize firebase with:

  1. Firebase.initializeApp({ credential: Firebase.credential.applicationDefault(), databaseURL: 'https://[PROJECTDB_NAME].firebaseio.com' })