title: Resolve "7 PERMISSION_DENIED: The caller does not have permission" when calling FirestoreAdminClient.exportDocuments
body: <p>This is how we are authenticating and calling the FirestoreAdminClient.</p>
  
  <pre><code>import fs from 'fs';
  import firebaseAdmin from 'firebase-admin';
  
  const pathToServiceAccountKeyFile = '/path/to/service/account/key.json';
  
  const serviceAccountKeyJSON = fs
    .readFileSync(pathToServiceAccountKeyFile)
    .toString();
  
  const serviceAccountKeyObject = JSON.parse(serviceAccountKeyJSON);
  
  firebaseAdmin.initializeApp({
    credential: firebaseAdmin.credential.cert(serviceAccountKeyObject)
  });
  
  const adminClient = new firebaseAdmin.firestore.v1.FirestoreAdminClient({
    keyFilename: pathToServiceAccountKeyFile
  });
  
  adminClient
    .exportDocuments({
      name: adminClient.databasePath('firebase-test-project-id', '(default)'),
      outputUriPrefix: 'gs://firebase-test-project-backups'
    })
    .then(response =&gt; console.log(response));
  </code></pre>
  
  <p>This is the output of the console.log statement.</p>
  
  <pre><code>7 PERMISSION_DENIED: The caller does not have permission
  
    at Object.callErrorFromStatus (node_modules/@grpc/grpc-js/build/src/call.js:30:26)
    at Http2CallStream.call.on (node_modules/@grpc/grpc-js/build/src/client.js:96:33)
    at process.nextTick (node_modules/@grpc/grpc-js/build/src/call-stream.js:75:22)
  </code></pre>
  
  <p>This is where we generated the service account key.</p>
  
  <p><a href="https://i.stack.imgur.com/7YQie.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7YQie.png" alt="enter image description here"></a></p>
  
  <p>References: </p>
  
  <p><a href="https://googleapis.dev/nodejs/firestore/latest/index.html" rel="nofollow noreferrer">https://googleapis.dev/nodejs/firestore/latest/index.html</a></p>