首页 文章

Google Apps脚本 - 获取用户的电子邮件地址

提问于
浏览
1

我在Google网站上运行了一个Google应用脚本项目 . 该网站要求用户登录,并且只向该G-suite域中的用户开放 .

我拥有的脚本是允许用户进行投票,进入扬声器队列以及其他一些任务 .

目前,后台的所有功能都可以正常运行,我喜欢“我”,但是我需要知道运行脚本的用户的电子邮件地址(查看Google网站) . 有没有办法让我查看正在运行脚本的页面的登录用户的电子邮件地址,同时像我一样运行实际脚本?

如果没有,我可以将一个脚本作为用户运行,然后调用另一个以我身份运行的脚本吗?

1 回答

  • 2

    你试过记录这些吗? https://developers.google.com/apps-script/reference/base/session#getActiveUser()

    // Log the email address of the user under whose authority the script is running.
     var email = Session.getEffectiveUser().getEmail();
     Logger.log(email);
    
    // Log the email address of the person running the script.
     var email = Session.getActiveUser().getEmail();
     Logger.log(email);
    

相关问题