title: How to read Drive Photos using Drive Rest API
body: <p>I'm trying to read Google Photos using Drive REST API inside Google Apps Script. The code looks like this:</p>
  
  <pre><code>function myFunction() {
    var files = Drive.Files.list({ 
      maxResults: 10,
      spaces: 'photos'    
    });
  
    for (var i = 0; i &lt; files.items.length; i++) {
      var f = files.items[i];
      Logger.log(f.title);
    }  
  }
  </code></pre>
  
  <p>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")"</p>
  
  <p><a href="https://i.stack.imgur.com/EaTZV.png" rel="nofollow noreferrer">Page with error</a>
  <a href="https://i.stack.imgur.com/EaTZV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EaTZV.png" alt="enter image description here"></a></p>
  
  <p>Project properties contain scope "<a href="https://www.googleapis.com/auth/drive" rel="nofollow noreferrer">https://www.googleapis.com/auth/drive</a>" - 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?</p>