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:
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)
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)!
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.:
The question is next: how to restore files which were created by application and how to "reset" Service Accounts - make them working?