简体   繁体   中英

How to add people to google groups programmatically using google app script?


  var form = FormApp.openById('1IErsge8yafg0UOltvhecAMhRd5Yh1VXJdhkI');
  var groupID = "mygroup@googlegroups.com";

  var formResponses = form.getResponses();
  for (var i = 0; i < formResponses.length; i++) {
    var formResponse = formResponses[i];
    var itemResponses = formResponse.getItemResponses();
    var email = itemResponses[1].getResponse();
    Logger.log(email);
    var newMember = {email: email, role: "MEMBER"};
    AdminDirectory.Members.insert(newMember, groupID);
  }

}

This is the code I've written and I'm getting an error在此处输入图像描述

After some research I found out that the error is because I don't have a G Suite subscription.

However, I am not able to find anything about how achieve the same task without a G Suite subscription. Can anyone please help me with that?

Thanks in advance!

As you aren't Google Workspace Admin, please checkout the Jay Lee's answer to Google Groups API add Member . Tl;Dr: AdminDirectory can be used only by Google Workspace Admins.

You might try to use the Groups Service to get information about a Google Group but it hasn't a method to add users to a group, so your only options are to add the users manually or to use web-browser automation tool.

Resources

Related

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM