添加“密码".输入到Google Apps脚本inputBox [英] Adding "password" type to Google Apps Script inputBox

查看:93
本文介绍了添加“密码".输入到Google Apps脚本inputBox的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将密码"类型分配给Google Apps脚本输入框,以使文本不显示?

Is it possible to assign the "password" type to the Google Apps Script inputBox so the text doesn't show?

以下内容工作正常,但输入字段是一个简单的文本框,显示的是文本,而不是••••••••":

The following is working just fine, but the input field is a simple textbox and displays the text rather than "••••••••":

Browser.inputBox('Please enter your password');

我有一个带有相关脚本的Google表格,该脚本会自动使用从外部API检索的信息填充某些单元格.该API需要简单的身份验证,因此这就是为什么我提示用户输入用户名和密码(这是内部工具,因此询问密码没有问题,没有被存储或其他任何东西).

I have a Google Sheet with an associated script that automatically populates some cells with information retrieved from an external API. The API requires simple authentication so that's why I'm prompting the user for their username and password (this is for an internal tool so there are no issues with asking for the password, it's not being stored or anything).

推荐答案

桑迪·古德斯评论,我结束了使用带有HTML服务的自定义对话框.

Per Sandy Good's comment, I ended up using a custom dialog with an HTML service.

以下方法非常适合显示"password"类型的输入并将值传递给我的Google脚本:

The following works great to show the input with type "password" and pass the value to my google script:

pw_input.html

<script>
  function updateInfo(form) {
    google.script.run.myOtherScript(form.password.value);
    google.script.host.close();
  }
</script>
<form>
  Password:
  <input type="password" name="password">
  <input type="button" value="OK" onclick="updateInfo(this.form)" />
</form>

main.gs

function myMainFunc() {

  onOpen();

  var html = HtmlService.createHtmlOutputFromFile('pw_input')
      .setSandboxMode(HtmlService.SandboxMode.IFRAME);
  SpreadsheetApp.getUi()
      .showModalDialog(html, 'Please enter your password');
};

other_script.gs

function myOtherScript(promptResponse) {
  etc...
};

这篇关于添加“密码".输入到Google Apps脚本inputBox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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