【问题标题】:Show account information in google apps script在 Google Apps 脚本中显示帐户信息
【发布时间】:2013-05-19 11:07:17
【问题描述】:

一旦用户登录到他的 Google 帐户,我正在尝试找到某种方法来从 Google 网站的 google 应用程序脚本小工具的控制面板中检索信息。

我找到了run the script as the user 的一种方法,并使用了Session.getActiveUser() 函数并将其部署在应用程序脚本小工具中。

不起作用,出现错误“脚本运行良好,但没有返回任何内容。”

这个问题有什么解决办法吗?还是我错过了其他展示所需信息的好方法?

【问题讨论】:

  • 你能贴一些代码吗?查看问题,您似乎有一个 doGet() 但没有从 doGet 返回 UiApp。
  • function doGet(e) { var value = logActiveUserEmail(); return value; } function logActiveUserEmail() { var email = Session.getActiveUser().getEmail(); Logger.log(email); } 好了

标签: google-apps-script google-sites


【解决方案1】:

正如我在评论中提到的,您没有返回 UiApp 对象。有关如何显示 UI 的信息,请参阅 Ui Service documentation。在非常基本的级别上,您可以使用以下代码

function doGet(e) 
{
 var app = UiApp.createApplication();
 var value = logActiveUserEmail();
 app.add(app.createLabel('Your email address is ' + value));

 // Return the UI App
 return app; 
} 

function logActiveUserEmail() 
{
 var email = Session.getActiveUser().getEmail();
 Logger.log(email); 
 return email;
}

【讨论】:

  • 哇,我缺乏太多对不起我是新手,感谢您提供有关 UIApp 的信息并感谢您的帮助 =)
猜你喜欢
  • 1970-01-01
  • 2017-01-02
  • 1970-01-01
  • 2019-05-16
  • 1970-01-01
  • 1970-01-01
  • 2011-02-13
  • 1970-01-01
  • 2016-10-12
相关资源
最近更新 更多