使用Google App Maker访问管理SDK [英] Access Admin SDK with Google App Maker

查看:77
本文介绍了使用Google App Maker访问管理SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在与抢先体验的Google App Maker进行练习,并希望创建一个简单的应用程序,允许管理员更改组织中另一个用户的密码.

I'm practicing with the early access Google App Maker and want to create a simple app that allows an administrator to change the password of another user in the organisation.

每当我尝试使用以前可以与App Script一起使用的东西调用Admin SDK API时,都会出现错误.看来App Maker不允许访问SDK API.

Whenever I try to call the Admin SDK API with something that would have previously worked with App Script, I get an error. It seems to be that App Maker is not allowing access to the SDK API.

我已经启用了高级服务">"Google Admin Directory API".这是我应该能够启用Admin SDK API(更改密码所必需的)的地方

I've enabled the Advanced Services > Google Admin Directory API. Is this where I should be able to enable the Admin SDK API (required for changing passwords)

要进行测试,我正在尝试运行这很简单功能:

To test, I'm trying to run this simple function:

function listUsers() {
  var response = AdminDirectory.Users.list(optionalArgs);
  var users = response.users;
  if (users && users.length > 0) {
    Logger.log('Users:');
    for (i = 0; i < users.length; i++) {
      var user = users[i];
      Logger.log('%s (%s)', user.primaryEmail, user.name.fullName);
    }
  } else {
    Logger.log('No users found.');
  }
}

上面的代码返回此错误:

The above code returns this error:

AdminDirectory is not defined at NewPage.Button1.onClick:2:18

我确定我在这里一定会遗漏一些东西.

I'm sure I must be missing something here.

非常感谢.

推荐答案

AdminDirectory(以及其他高级服务)仅在服务器端可用.

AdminDirectory (As well as other advanced services) are available on server side only.

您应将方法移至服务器脚本",然后单击google.script.run对其进行调用.

You should move the method to Server Script and call it with google.script.run on button's click.

请使用代码完成功能查看可用选项.

Please use code completion to see available options.

这篇关于使用Google App Maker访问管理SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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