4

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 enter image description here

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?

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
eshangin
  • 99
  • 1
  • 11

1 Answers1

2

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"

Linda Lawton - DaImTo
  • 106,405
  • 32
  • 180
  • 449
  • 2
    Can you tell how to require this particular scope in App Script? App Script usually automatically require scopes when for example we use DriveApp in the code... But how to manually require particular scope?! – eshangin May 27 '16 at 13:56
  • Also when I call Drive API with spaces 'photos' on https://developers.google.com/drive/v3/reference/files/list#try-it it enough to include just 'https://www.googleapis.com/auth/drive' scope. – eshangin May 27 '16 at 13:59
  • it is not you need to have one of the other ones as well. https://www.googleapis.com/auth/drive.photos.readonly or https://picasaweb.google.com/data/ – Linda Lawton - DaImTo May 27 '16 at 14:00
  • Ok, but do you know how to request this particular scope in Apps Script? – eshangin May 27 '16 at 14:01
  • Also as I said I'm able to use just scope 'googleapis.com/auth/drive' on https://developers.google.com/drive/v3/reference/files/list page to make the same request. See this screenshot http://content.screencast.com/users/eshangin/folders/Jing/media/8c02d416-8afd-4ea9-806d-d9b9ebb6e4ea/2016-05-27_2019-ex.png. Why it is possible? – eshangin May 27 '16 at 14:22