If I create a new folder in google drive web interface, the metadata is not retrieved via a call from api in c#.
However if I upload files or create folders via api, the metadata is returned as expected.
Problem is the opposite (almost) of this one, where the user cannot see files in the web interface uploaded via api... I can't see the files and folders created via code in my Google Drive
All files are visible for me in the google drive web interface, but I only get details of those created via api in my code, below.
(edit) I should add, I've tried using every 'DriveService.Scope' available to me.
(edit2) I have observed that if I change ApplicationName, none of the previously uploaded files are retrieved either, but new uploads are.
FilesResource.ListRequest listRequest = service.Files.List();
listRequest.PageSize = 10;
listRequest.Fields = "nextPageToken, files(id, name, size, mimeType)";
IList<Google.Apis.Drive.v3.Data.File> files = listRequest.Execute().Files;
return files;
CTOR
public GoogleDrive(string appname)
{
ApplicationName = appname;
error = new Error();
try
{
credential = GetCredential();
}
catch(Exception ex)
{
error = ex as Error;
}
try
{
// Create Drive API service.
service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = this.ApplicationName,
});
}
catch (Exception ex)
{
error = ex as Error;
}
}
GetCredential method
private UserCredential GetCredential()
{
UserCredential credential;
try
{
using (var stream =
new FileStream("client_secret.json", FileMode.Open, FileAccess.Read))
{
string credPath = System.Environment.GetFolderPath(
System.Environment.SpecialFolder.Personal);
credPath = Path.Combine(credPath, ".credentials/gd-cred-" + ApplicationName + ".json");
credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
GoogleClientSecrets.Load(stream).Secrets,
Scopes,
"user",
CancellationToken.None,
new FileDataStore(credPath, true)).Result;
}
return credential;
}
catch (Exception ex)
{
error = ex as Error;
return null;
}
}