如何使用Drive Rest API阅读Drive Photos

时间:2016-05-27 11:16:50

标签: google-apps-script google-drive-api picasa google-photos

我正在尝试使用Google Apps脚本中的Drive REST API阅读Google相册。代码如下所示:

function myFunction() {
  var files = Drive.Files.list({ 
    maxResults: 10,
    spaces: 'photos'    
  });

  for (var i = 0; i < files.items.length; i++) {
    var f = files.items[i];
    Logger.log(f.title);
  }  
}

但是,如果我运行此功能,Google会显示错误“授予的范围不允许访问所有请求的空格。(第2行,文件”代码“)”

Page with error enter image description here

项目属性包含范围“https://www.googleapis.com/auth/drive” - 即所有对象都应该可用。但由于某种原因,我得到了这个错误。我认为这是Google Apps脚本中的一个错误。有什么想法吗?

1 个答案:

答案 0 :(得分:2)

照片实际上并不是Google Drive API V3的一部分,而是Picasa网络相册数据API的一部分,因为您需要使用Picasa网络相册数据API范围进行身份验证。

  

https://picasaweb.google.com/data/

  

https://www.googleapis.com/auth/drive.photos.readonly

只需将该范围添加到您的脚本中它应该可以工作然后您只能

  

https://www.googleapis.com/auth/drive

相关问题