title: GAS - "You do not have permission to call SpreadsheetApp.openById"
body: <p>One of my scripts uses <code>SpreadsheetApp.openById(ID)</code> to get data from a spreadsheet. The script has been given the permissions to open the file, and the user of the script has write access on the file. However, sometimes, the script returns the following error : </p>
  
  <pre><code>You do not have permission to call SpreadsheetApp.openById. Required permissions: https://www.googleapis.com/auth/spreadsheets at [unknown function](Code:11)
  </code></pre>
  
  <p>Other times, there are no issue and the script works perfectly. Any idea/help on how to fix this?</p>
  
  <p>Script example :</p>
  
  <pre><code>var spreadsheet = SpreadsheetApp.openById("1m65QVfk9Xx2zOwUxewdSjWCDK-g_jHj7ETFVFF0rjxY")
  
  function myFunc() {
    sheet = spreadsheet.getActiveSheet()
    prepareHours()
    inputDisplays()
  }
  </code></pre>