如何使用Drive Rest API读取驱动器照片 [英] How to read Drive Photos using Drive Rest API

查看:229
本文介绍了如何使用Drive Rest API读取驱动器照片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to read Google Photos using Drive REST API inside Google Apps Script. The code looks like this:

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显示错误The (第2行,文件代码)

But if I run this function Google shows error "The granted scopes do not give access to all of the requested spaces. (line 2, file "Code")"

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

Project properties contain scope "https://www.googleapis.com/auth/drive" - i.e. all objects should be available. But for some reason I get this error. I think it is a bug in Google Apps Script. Any thoughts?

推荐答案

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

Photos isn't actually part of the Google Drive API V3 its part of Picasa Web Albums Data API because of that you need to be authenticated using the Picasa Web Albums Data API scope.


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


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

只需将该范围添加到您的脚本中即可, b
$ b

Just add that scope to your script it should work then you cant only


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

这篇关于如何使用Drive Rest API读取驱动器照片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆