title: Is there a way to exclude files not explicitly shared with the user from a script? ( aka files that are Shared with Everyone In Domain With The Link)
body: <p>I'm trying to write a script that will return the name of every file that has been shared with the active user. However I'm having problems with the .getAccess() method.</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>So I've been tinkering with the code a little and it turns out that the code is breaking on files that are shared with "Everyone in the domain who has the link". So now the issue is that of avoiding files that are shared with everybody but are still popping up in the user's drive without having been explicitly shared with them. </p>
  
  <p>Is there a way to say:</p>
  
  <pre><code>if (file.getAccess(user) == "VIEW" &amp;&amp; file is explicitly shared with user)
  
  or
  
  &amp;&amp; file is not "Shared with everyone in the domain with the link"
  </code></pre>
  
  <p><strong>OLD QUESTION:</strong>
  When I use it on a file that was accessed from a specific ID, it works perfectly. 
  For example:</p>
  
  <pre><code>var id = "1HoJbszb1uLF1RZpU_IPv3O648pIeYs4IWK2kbbQ4IaA";
  var file = DriveApp.getFileById(x);
  
  Logger.log(file.getAccess(user));
  </code></pre>
  
  <p>Log:</p>
  
  <pre><code>EDIT
  </code></pre>
  
  <p>However, if I try to iterate through every file in a user's drive, I will get an error "No Item with the given ID could be found, or you do not have permission to access it".</p>
  
  <p>I've tried it these two ways:</p>
  
  <pre><code>  while (files.hasNext()){
      var raw = files.next();
      var id = raw.getId();
      var file = DriveApp.getFileById(id);
      if (file.getAccess(user) == "EDIT" ) Logger.log(file.getAccess(user));
    }
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>  while (files.hasNext()){
      var file = files.next();
      if (file.getAccess(user) == "EDIT" ) Logger.log(file.getAccess(user)); 
    }
  </code></pre>
  
  <p>I get the same error trying it both ways. I've even checked to make sure that the .hasNext() method is working and to be sure when I ask the log to only list the names of each file it works fine as long as .getAccess() is never called (so no if statement). </p>
  
  <pre><code>while (files.hasNext()){
    var file = files.next();
    Logger.log(file.getName());
  }
  </code></pre>
  
  <p>any idea what's wrong?</p>