title: Google Scripts: Library doesn't work unless explicily shared
body: <p>There's a certain type of Google script hat I need to run on several Google spreadsheets that our company utilizes. The only thing that needs changing per spreadsheet is the range that script needs to manipulate.</p>
  
  <p>To avoid having to copy-paste the code from spreadsheet to spreadsheet, I decided to make a library, and link each spreadsheet to that library (by adding the script key in each spreadsheet's script editor). </p>
  
  <p>The main library function simply takes the sheet name of every spreadsheet, and the range to apply the code to. </p>
  
  <p>This is all done from my account, which is also the owner of those spreadsheets.</p>
  
  <p>The spreadsheets themselves are shared with several people, and that number might grow quite a bit in the future. Different emails will be granted access to different spreadsheets.</p>
  
  <p>Today, an account with <strong>editing rights for one of the sheets</strong> that utilizes the library reported that the spreadsheet wasn't functioning properly. I entered the spreadsheet script editor, and upon trying to run the script manually from that account to debug, I got an error message along the lines of "you don't have access to the library". </p>
  
  <p>After following advice given in a Google Products forum, I granted this account view-only rights to the library. The script then worked fine.</p>
  
  <p>However, this is not a good solution: People with edit access to any spreadsheet utilizing the library can invite other people to edit the spreadsheet. Obviously, new invitees won't have read-only rights of the library, so the script will fail for them. Adding those people one by one to the library one by one will be very laborious.</p>
  
  <p>How can I make library work for any user, even if they don't have access to the library, but do have access to the spreadsheet utilizing he library? I can't expose my code publicly, but I don't mind exposing it to people in my company.</p>