title: How do I delete files from a shared folder using Google Drive V3?
body: <p>I'm trying to build a feature that deletes old files in a <strong>shared</strong> Google drive folder as follows:</p>
  <pre><code>private async deleteExpiredFiles(
    dataType: DataType,
    folderId: string,
    expirationDate: string,
  ): Promise&lt;void&gt; {
    const {
      data: { files: filesToDelete },
    } = await this.drive.files.list({
      q: `'${folderId}' in parents and createdTime &lt;= '${expirationDate}'`,
      supportsAllDrives: true,         
      includeItemsFromAllDrives: true,
    });
  
    if (!filesToDelete) {
      return;
    }
  
    await Promise.all(
      filesToDelete.map(async (file) =&gt; {
        if (!file.id) {
          return;
        }
  
      const permissionIds = await this.drive.permissions.list({
        fileId: file.id,
          supportsAllDrives: true,
        });
  
        if (!permissionIds.data.permissions) {
          return;
        }
  
        Promise.all(
          permissionIds.data.permissions.map(async (permission) =&gt; {
            if (!permission.id || !file.id) {
              return;
            }
  
            await this.drive.permissions.delete({
              fileId: file.id,
              permissionId: permission.id,
              supportsAllDrives: true,
            });
          }),
        );
      }),
    );
  }
  </code></pre>
  <p>I have set up all the permission in the Google Drive folder as well as get the correct credentials for the service account. However when I try to run this, I get the following error: <code>GaxiosError: The authenticated user does not have the required access to delete the permission.</code></p>
  <p>I can use drive.files.list fine and see the files as well as list the permission ids. But it isn't letting me delete them. Any advice?</p>