使用.NET Core的Google.Apis.Core,当我指定空格=“照片”时为什么为什么看不到Google相册中的照片列表?

问题描述 投票:0回答:1

示例代码如下:

static string[] Scopes = { DriveService.Scope.Drive, DriveService.Scope.DrivePhotosReadonly };
static string ApplicationName = "Quickstart";

UserCredential credential;

            using (var stream = new FileStream("credentials.json", FileMode.Open, FileAccess.Read))
            {
                string credPath = "token.json";
                credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                    GoogleClientSecrets.Load(stream).Secrets,
                    Scopes,
                    "user",
                    CancellationToken.None,
                    new FileDataStore(credPath, true)).Result;

            }

            // Create Drive API service.
            var service = new DriveService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = credential,
                ApplicationName = ApplicationName,
            });

            // Define parameters of request.
            FilesResource.ListRequest listRequest = service.Files.List();
            listRequest.Spaces = "photos";
            listRequest.PageSize = 100;
            listRequest.Fields = "nextPageToken, files(id, name)";

            // List files.
            IList<Google.Apis.Drive.v3.Data.File> files = listRequest.Execute().Files;
            Console.WriteLine("Files:");
            if (files != null && files.Count > 0)
            {
                foreach (var file in files)
                {
                    Console.WriteLine("{0} ({1})", file.Name, file.Id);
                }
            }
            else
            {
                Console.WriteLine("No files found.");
            }
            Console.Read();

我通过Google控制台启用了Google Drive API,并获取了certificate.json文件。当我使用listRequest.Spaces =“ drive”运行此驱动器时,我可以看到所有驱动器文件,但是将其设置为“ photos”时看不到任何照片。

这里还需要其他哪种未公开的魔法才能起作用?

谢谢。

google-api google-drive-api
1个回答
0
投票

[Google云端硬盘和Google相册已为disconnected,空格“照片”已为deprecated

但是,有Google Photos API可以让您list您的照片。

© www.soinside.com 2019 - 2024. All rights reserved.