title: Google Apps Script Permissions for a function with inputs
body: <p>I know this topic has bee covered before sort of, but none of it really makes sense to me. Basically I wrote a function that will generate a PDF from some API data using user inputs. It looks vaguely like this and works when I run it in the script editor.</p>
  <p><a href="https://i.stack.imgur.com/lQlNr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lQlNr.png" alt="enter image description here" /></a></p>
  <pre><code>function myfunction(InputA,InputB,InputC,InputD,InputE) {
  
  ......
  
  var sourceSpreadsheet = SpreadsheetApp.getActive();
      var parents = DriveApp.getFileById(sourceSpreadsheet.getId()).getParents();
      if (parents.hasNext()) {
        var folder = parents.next();
      }
  
      var response = UrlFetchApp.fetch(url, options)
      var blob = response.getAs('application/pdf').setName(InputA + InputB + InputC)
      var newFile = folder.createFile(blob);
  
      return newFile
  }
    
  </code></pre>
  <p>The problem is Google permissions. The classic: &quot;You don't have permission to access the drive&quot;.</p>
  <p>I have tried publishing the script as a private sheets addon and enabled it on my spreadsheet. But that didn't really do anything. And I don't really know why because I authorized the app for all the required scopes when I approved the add on. I can see it in the extensions menu but I am still getting errors when I try to call the function.</p>
  <p>The button method of enabling permissions doesn't work for me because I need to run the code several times based on parameters defined in the Sheet. I tried simple triggers since I want the code to run weekly anyways, but found the same problem.</p>
  <p>Can someone give me the step by step of how I'm supposed to do this.</p>
  <p>Please don't send links to the google documentation because I have read the related pages and still don't know what I'm doing wrong.</p>