问题
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