Google网上论坛API-getUsers()您无权查看该网上论坛的成员列表: [英] Google Groups API - getUsers() You do not have permission to view the member list for the group:

查看:112
本文介绍了Google网上论坛API-getUsers()您无权查看该网上论坛的成员列表:的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为大家加油!

我有一个Google脚本,该脚本通过使用getUsers()函数检查电子邮件地址是否是组的成员.

I have a Google script which checks if e-mail addresses are members of a group or not by using getUsers() function.

到目前为止:

  • 我已激活"Admin SDK目录服务"
  • 我具有管理员权限

对于大多数组来说,这确实是不可思议的,但是在某些组的情况下,我会收到授权错误.

For most of the groups it does it's magic, however I get authorization error in case of some groups.

日志中的错误消息:

  • 您无权查看该组的成员列表:foo @ bar"

任何想法可能是什么问题? 非常感谢. 谢谢!

Any idea what might be the problem? Anything is very much appreciated. Thank you!

推荐答案

问题是GroupsApp服务使用GROUP的权限来确定您是否可以查看成员列表.组的默认设置是将访问权限限制为组的所有者和管理员.因此,您有两种选择:

The problem is that the GroupsApp service uses the permissions of the GROUP to determine whether or not you can view the members list. The default setting for groups is to restrict this access to owners and managers of the group. So you have two options:

1)让自己成为该论坛的所有者或经理,或者

1) Make yourself an owner or manager of the group OR

2)使用Admin SDK检查组成员身份. Admin SDK允许任何超级管理员查看组中的用户列表.要确定用户是否为组的成员,您需要检索该组,然后遍历成员列表,然后将每个成员与您要查找的用户进行比较:

2) Use the Admin SDK to check for group membership. The Admin SDK allows any super admin to view the list of users in a group. To find out whether a user is a member of a group, you would need to retrieve the group, then iterate through the members list and then compare each member against the user you are looking for:

 function isMember(groupKey,userKey){
    //groupKey: testGroup@yourdomain.com
    //userKey: userEmail@yourdomain.com 

    var memberList = [];

    //Get the members list from the group
    var response = AdminDirectory.Members.list(groupKey);
    memberList = memberList.concat(response.members);
    while (response.nextPageToken){
      response = AdminDirectory.Members.list(groupKey,{pageToken: response.nextPageToken});
      memberList = memberList.concat(response.members);
    }

    if (memberList.length > 1){

      for (var x in memberList){
        if (memberList[x].email == userKey){return true;}
     }
   }
 }

更多信息此处

这篇关于Google网上论坛API-getUsers()您无权查看该网上论坛的成员列表:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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