问题
I have an addon shared to all domain-users. It opens a sidebar that contains a form.
I want the form to post to another Apps Script (implemented webapp) in a basic client-server fashion. The other script (runs as admin) should do stuff with the user-submitted data.
Script1.html (in addon, any user can run it)
<form id="myForm" method="post" action="https://script.google.com/a/macros/<domain>/s/<script2-id>/exec">
<input name="name" type="text" value=""/>
<input name="message" type="text" value=""/>
<input type="button" value="send" formmethod="post" onclick="google.script.host.close();" />
</form>
Script2 (always runs by same admin)
function doPost(formInfo){
doStuff(formInfo.name,formInfo.message)
}
Is this possible? What am I doing wrong. Can this be done in a secure way?
回答1:
It works with no security (anyone can access, even anonymously) on the webapp. Otherwise it will force a Google Signin.
sidebar.html (from client-script.gs)
<form id="myForm" target="_self" method="post" action="https://script.google.com/macros/s/SCRIPT_ID/exec">
<input name="name" type="text" value=""/>
<input name="message" type="text" value=""/>
<input type="submit" value="send" />
</form>
来源:https://stackoverflow.com/questions/35361864/want-to-post-from-a-apps-script-form-to-another-app-script