How to read Drive Photos using Drive Rest API

ⅰ亾dé卋堺 提交于 2021-02-18 15:35:04

问题


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);
  }  
}

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")"

Page with error

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?


回答1:


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/

or

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

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

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



来源:https://stackoverflow.com/questions/37482119/how-to-read-drive-photos-using-drive-rest-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!