Want to post from a Apps Script form to another App Script

三世轮回 提交于 2019-12-23 21:17:17

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!