We have created a Google apps script for mail-merge purposes. We open a Google document and onOpen a script will run for selecting a spreadsheet with addresses and after selecting a spreadsheet we need to authorize the code. We can authorize within the script editor, but this document will be copied for every mail-merge type and therefor the end-user needs to authorize. Well here's where the problem occurs. The end-user will only get the message.
"Error encountered: Authorization is required to perform that action."
Okay fine, but the popup which normally shows by web-apps doesn't appear. So the user can't authorize at all. We can't ask our end-users to go to the script editor and run the code ones, so they will be able to authorize.
Can we popup the authorization code manually in the script?
Here is a routine I use in document embedded scripts that use only normal GAS services, try it to see if it meets your requirements.
code.gs :
index1.html :
index2.html :