Writing an application that will crawl an uploads directory for packaged zip files uploaded by users, and recreate the in-zip directory structure in a Google for Work shared google drive folder.
Problem: The shared folder is not accessible or visible to the service account created in the For Work domain. Code is in C#. I hope I'm just missing something stupid.
Details: Logged in as the domain admin account. Go into the google api console, enable api, create a service account, grant access to that service account's email. Via API and service account, shared folder is not found in the list of File objects, nor can I upload to it by ID.
The following snippet is called using the in-url folder ID of the shared folder. The folder that is shared to the service account doesn't show up in the list of stuff returned.
// get starting point
string masterParent = "xxxxx"; // pulled from URL after sharing folder
File masterParentFolder = GetGAPIFileById( service, masterParent, false );
Example Snippet:
static File GetGAPIFileById( gapi.DriveService service, string id, bool folderOnly ) {
if( null == id ) id = "-1";
File rtn = null;
var lreq = service.Files.List();
lreq.MaxResults = 10000;
if( folderOnly ) {
lreq.Q = "mimeType='application/vnd.google-apps.folder' and trashed=false";
} else {
lreq.Q = "trashed=false";
}
var lres = lreq.Execute();
foreach( File f in lres.Items ) {
Console.WriteLine( "Item: " + f.Title + " // " + f.Id );
if( f.Id.Trim().ToLower() == id.Trim().ToLower() ) {
rtn = f;
break;
}
}
return rtn;
}