Dercni
Dercni

Reputation: 1224

GCP - Uploading data to Firestore from CSV

I have a CSV file I am using to upload data to our Firestore database.

The file has 16,000 records.

I am using the Google Cloud Platform CLI to upload the data via a node.js script.

The import works until it has imported approximately 3,000 records and then crashes.

The CLI displays the following error:

Error: 16 UNAUTHENTICATED: Request had invalid authentication credentials. Expected OAuth 2 access token, login cookie or other valid authentication credential.

Upvotes: 1

Views: 337

Answers (1)

Catch the error and reconnect calling the Firebase object again:

const {Firestore} = require('@google-cloud/firestore');

// Create a new client
const firestore = new Firestore();

try {
  //my program with the error...
}
catch (e) {

   //request a new client:
   const firestore = new Firestore();
   //keep going...
}

Upvotes: 2

Related Questions