Google Groups API - getUsers() You do not have permission to view the member list for the group: -
cheers everyone!
i have google script checks if e-mail addresses members of group or not using getusers() function.
so far:
- i have activated "admin sdk directory service"
- i have admin authority
for of groups it's magic, authorization error in case of groups.
error message log:
- "you not have permission view member list group: foo@bar"
any idea might problem? appreciated. thank you!
the problem groupsapp service uses permissions of group determine whether or not can view members list. default setting groups restrict access owners , managers of group. have 2 options:
1) make owner or manager of group or
2) use admin sdk check group membership. admin sdk allows super admin view list of users in group. find out whether user member of group, need retrieve group, iterate through members list , compare each member against user looking for:
function ismember(groupkey,userkey){ //groupkey: testgroup@yourdomain.com //userkey: useremail@yourdomain.com var memberlist = []; //get members list 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){ (var x in memberlist){ if (memberlist[x].email == userkey){return true;} } } }
more info here
Comments
Post a Comment