I have created an Apps Script that replaces token in Google Doc. This App Script has been deployed as API Executable. I am able to run a function in the apps script editor without any authorization error. But, it fails sometimes with Authorization error when invoked from my java web application. I get the following error:
{
"name": "replaceTokensInDoc",
"done": true,
"error": {
"code": 3,
"message": "ScriptError",
"details": [
{
"@type": "type.googleapis.com/google.apps.script.v1.ExecutionError",
"errorMessage": "Authorization is required to perform that action.",
"errorType": "ScriptError"
}
]
}
}
I have read in multiple places that I need to just run a function in Script Editor and provide permission to solve this issue, but it hasn't helped in my case. When I run a function in the editor, it doesn't even show the authorization dialog, which means it has all the necessary permissions. It only fails sometimes. Could somebody let me know the reason for this strange behavior?