0

I have such a situation: There is an firebase application which uses Admin SDK with Firebase callable functions and Google API, and Google Drive API. There is a folder which contains 9 files uploaded by the application, using Google Drive API Google Drive API but those files are not visible!

When I share the folder with a new user the Information panel shows that new permissions were added to files inside the folder as well:

List of files in the folder

But when I try to view the file - it shows the black box with message that file is not accessible... and after that I see a new empty file generated in the folder instead!

Unknown users - new Service Accounts, and the Deleted User - the deleted Service Account which was used by application (and which created those files)

Trying to view the file

New file instead

API Explorer doesn't show any files in the folder (with parameters: "parents": "folder_id", "fields: "*"): https://developers.google.com/drive/api/v3/reference/files/create?apix=true

Trying to download files https://drive.google.com/a/nbmrteam.com/uc?export=download&id=file_id returns "File not found)! File not found

I have written the Script (Google Apps Script) which loop through all files in the folder but it doesn't see files as well:

function getListOfFiles(folderId) {
  try { 
    Logger.log("getListOfFiles()---------------------------");
    Logger.log("folderId: " + folderId);

    var result = {
      msg: "NOT FOUND",
      files: null
    };

    var destFolder = null;
    var exists = false;  
    var fileData = [];

    if(folderId) {
      destFolder = DriveApp.getFolderById(folderId); //.getFiles()
    } else {
      destFolder = DriveApp.getRootFolder(); 
    }

    if(destFolder) {
      //if(!destFolder) return result;

      var files = destFolder.getFiles();

      while (files.hasNext()) {
        var file = files.next();

        var data = {
          name: file.getName(),
          id: file.getId(),
          url: file.getUrl(),
          isTrashed: file.isTrashed(),
          size: file.getSize()
        }

        fileData.push(data);
        Logger.log(file.getName());

        result.files = JSON.stringify(fileData);
        result.msg = "OK";
      }
    }

    return result;

  } catch (err) {
    Logger.log(err.toString());
    return err.message;
  }
}

Also using new Service Accounts keys didn't help!

Also this application used the same Service Account key (Admin SDK Key) to fetch data from the Spreadsheet, but now it doesn't recognise a new Access Tokens:

Error: Request had invalid authentication credentials.:
Authorisation error
Error: Request had invalid authentication credentials.

The question is next: how to restore files which were created by application and how to "reset" Service Accounts - make them working?

Alex Pilugin
  • 683
  • 2
  • 10
  • 38
  • I received an advice that perhaps disappeared documents are orphaned since their owner (Service Account) was deleted... also I am going to use gapi.auth2 instead google.auth.JWT library to generate Access Token... – Alex Pilugin Dec 13 '18 at 12:08
  • We lost all files which were uploaded using previous Service Account... – Alex Pilugin Dec 14 '18 at 09:28

0 Answers0