Main Issue:
I have two Google spreadsheets: a template and a master.
The template is sent out to people to make a copy of, fill in, and then I have a script that copies their tab to the master spreadsheet.
Currently the authorization is very broad- to view, edit, delete all of the users' spreadsheets. Since only two files are involved, I'd like to narrow the scope to just those two, mainly because the authorization process looks sketchy to the users right now.
Is there a way to limit scope to specific spreadsheets vs all spreadsheets?
What I've found/researched so far:
It seems that you can easily only limit scope to the current file, or demand access to all spreadsheets.
I've found two methods:
1) current only
Add this to the top of the script:
/**
* @OnlyCurrentDoc
*/
This means that I can't copy the tab to the master spreadsheet.
2) Set Explicit Scopes Go into the manifest as described here: https://developers.google.com/apps-script/concepts/scopes Seems that this also only allows for current file only or full spreadsheet access.
Similar Questions:
Others have asked similar questions but haven't gotten an answer to this specific issue where there are multiple specific files in question.
How to use narrower Google Apps Script Authorization Scope when accessing file from own drive
How to narrow down the auth/drive scope for a google apps script?
Code and potential ideas:
I haven't tried whitelisting- could that help? Would I whitelist the master spreadsheet on the template?
The authorization when I tried '@OnlyCurrentDoc' defines the permission as 'View and manage spreadsheets that this application has been installed in'. Can I install this application in my master spreadsheet and have them talk? Any ideas?
//this is pretty much the only applicable code:
var admin_ss = SpreadsheetApp.openById([ID]);
var this_ss = SpreadsheetApp.getActiveSpreadsheet();
CurrentOnly scope:
https://www.googleapis.com/auth/spreadsheets.currentonly
doPost()
function to receive and authorize any request to write to the master spreadsheet from the slave spreadsheets.Drive.file scope:
https://www.googleapis.com/auth/drive.file