Access Admin SDK with Google App Maker

孤者浪人 提交于 2019-12-24 06:39:09

问题


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.

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.

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.

Many Thanks.


回答1:


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

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.



来源:https://stackoverflow.com/questions/47442099/access-admin-sdk-with-google-app-maker

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!