Reputation: 813
A
and B
.X
is protected and can be edited only by user A
.B
should use a script with user A
permissions to edit column X
.From reading the various documentation (https://developers.google.com/apps-script/guides/services/authorization), I understand that there are two ways to run a script on a google sheet as a different user.
doGet
and doPost
. All the examples that I saw were using the google script to edit the cells, which slammed me back to the permissions issue.Upvotes: 2
Views: 130
Reputation:
A possible solution: User A should deploy the web app with settings "execute as me [that is, A]", and choose access level as "anyone" [so that user B can access] or "anyone, even anonymous" to save user B an extra step and allow them to access the app programmatically. To prevent users other than B from editing, A gives B an access token, which B uses in their GET or POST requests. For example: user B accesses the app via GET request to https://..../exec?key=mykey
, and the app has code like this:
function doGet(e) {
if (e.parameter.key == "mykey") {
var ss = SpreadsheetApp.openById("spreadsheet Id"); // can't use getActiveSpreadsheet in doGet/doPost
// do something with the spreadsheet
}
}
Documentation: doGet/doPost event object.
Upvotes: 4