Unable to create an Installble trigger on a spreadsheet

Viewed 159

I've created a WebApp which takes a spreadsheet id, a trello's list id, trello api key and a user's trello token as input.

Upon getting the input, the Google app script creates an installable trigger on the spreadsheet such that the trigger will get executed whenever someone submits the google form linked with the spreadsheet and creates a trello card in the specified trello list.

Initially I tested this script by creating a google form (and hence a google sheet) and by giving the script the required input mentioned above. This worked completely fine, the script was successfully able to create a trigger on the specified spreadsheet.

The problem was that the google form and the google app script project were both linked to my Google account and hence there was no trouble for me to access my own resources programmatically. As soon as I tried to create a trigger on a sheet that was of some other user I was not allowed to do so.

I had published this script as webapp with execute app permission as Me and anonymous access to the app.

Permission settings for the script

I used Postman to make the api calls to the script and when submitting the input required to create the trigger I'm getting an HTML that says this:

enter image description here

I also tried to change the execution permissions to this:

enter image description here

But then got this response:

enter image description here

I'm assuming that I'll need to get permission from the user to be able to set a trigger on his/her resource but I'm not sure how to achieve that any suggestions would be appreciated.

Just for the sake of completeness, here is the code to set up a trigger on a spreadsheet.

function getTrigger(data){

    return ScriptApp.newTrigger("createTrelloCard").forSpreadsheet(data["spreadsheet_key"])
        .onFormSubmit()
        .create();
}
0 Answers
Related