title: how to solove 'Login Required' problem when using google sheet script?
body: <p>The goal is whenever a new version was created, an auto-trigger function will get this spreadsheet's latest history version date and set it to the target cell.</p>
  <p>I use onEdit function to trigger it.</p>
  <p>The code is like this:</p>
  <pre><code>function listRevisions(fileId) {
    var revisions = Drive.Revisions.list(fileId)
  
    if (revisions.items &amp;&amp; revisions.items.length &gt; 0) {
  
      var latestVersion = revisions.items[revisions.items.length - 1]
  
      var date = new Date(latestVersion.modifiedDate)
  
      Logger.log('Date: %s, File size (bytes): %s', date.toLocaleString(), latestVersion.fileSize);
      return date.toLocaleString()
    } 
    else {
      Logger.log('No revisions found.')
      return 
    }
  }
  
  function onEdit(e){
    if(e.source.getActiveSheet().getName()===&quot;targetSheetName&quot;){
      var dateString =  listRevisions(SpreadsheetApp.getActiveSpreadsheet().getId())
      targetSheet.getRange(1,7,1,1).setValue(dateString )
    }
  }
  </code></pre>
  <p>I can manually run listRevisions function and its fine with me,the problem is when I excute the listRevisions function by onEdit.It always give me a error text like</p>
  <blockquote>
  <p>&quot;GoogleJsonResponseException: API call to drive.revisions.list failed with error: Login Required
  at listRevisions&quot;</p>
  </blockquote>
  <p>Since I am not quite familier with google api stuff,could someone kindly help me figure out how to solove this problem?</p>