我试图从文件中找出父母的价值来找出某些文件夹的内容。我正在使用 API 版本 3。出于某种原因,Google 不允许知道属性“父母”,总是返回 null。
可能是什么原因?我以为这是一个有限的“范围”参数,但是扩展权限,结果是一样的。
所以我连接:
string[] scopes = new string[] { DriveService.Scope.Drive, DriveService.Scope.DriveFile, DriveService.Scope.DriveMetadata, DriveService.Scope.DriveAppdata};
var clientId = "id"; // From https://console.developers.google.com
var clientSecret = "secret"; // From https://console.developers.google.com
var credential = GoogleWebAuthorizationBroker.AuthorizeAsync(new ClientSecrets
{
ClientId = clientId,
ClientSecret = clientSecret
},
scopes,
Environment.UserName,
CancellationToken.None,
new FileDataStore("MyAppsToken111")).Result;
DriveService service = new DriveService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = "MyAppName",
});
所以我得到例如文件:
var list = service.Files.List().Execute().Files;
foreach (var file in list)
{
Console.WriteLine(file.Parents == null);//always: true == (file.Parents == null)
}
我确信至少一个文件必须具有非空父属性。你能告诉我我错过了什么吗?