想要从Apps脚本表单发布到另一个应用脚本 [英] Want to post from a Apps Script form to another App Script

查看:116
本文介绍了想要从Apps脚本表单发布到另一个应用脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个插件分享给所有域用户。
它打开一个包含表单的边栏。

I have an addon shared to all domain-users. It opens a sidebar that contains a form.

我希望表单以基本的客户端 - 服务器方式发布到另一个Apps脚本(实现的webapp)。
另一个脚本(以admin身份运行)应该使用用户提交的数据进行操作。

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(作为插件,任何用户都可以运行它)

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(始终由相同的管理员运行)

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?

推荐答案

它在web应用程序中没有任何安全性(任何人都可以访问,甚至匿名) 。否则它会强制Google Signin。

It works with no security (anyone can access, even anonymously) on the webapp. Otherwise it will force a Google Signin.

sidebar.html(来自client-script.gs)

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>

这篇关于想要从Apps脚本表单发布到另一个应用脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆