3 ms·
GAM is awesome for this. We've also had good luck with Google Apps Scripts. The advantage is that it makes it marginally easier to set up credentials: it does s
by lvh 8y ago
GAM is awesome for this. We've also had good luck with Google Apps Scripts. The advantage is that it makes it marginally easier to set up credentials: it does so behind the scenes so you never have creds with admin permissions hit disk. The disadvantage is you're now editing an old-ish version of JavaScript in a janky browser editor that saves to some weird bespoke JSON format. You can also use clasp (https://github.com/google/clasp https://github.com/google/clasp) to edit these files from your favorite editor but now you own a Software Engineering Project.
Here's roughly what that looks like to get all the mentioned info out:
function getGroups(domain) {
var groups = [], pageToken, page;
do {
page = AdminDirectory.Groups.list({
domain: domain,
maxResults: 100,
pageToken: pageToken
});
if (page.groups && page.groups.length > 0) {
groups = groups.concat(page.groups);
}
pageToken = page.nextPageToken;
} while (pageToken);
return groups;
}
function getGroupPerms(groups) {
var perms = [];
for (var i = 0; i < groups.length; i++) {
perms.push(AdminGroupsSettings.Groups.get(groups[i].email));
}
return perms;
}
Disclaimer: I'm the author of the linked blog post.
- jmathai 8y agoApps Script has a lot of potential when it comes to Groups (and other resources a company has to manage). As you said, clasp is an alternative to the web UI. What’s an ideal platform you’d like to see for easily executing code on to work with groups (Apps Script, Cloud Functions, or other)?
- lvh 8y agoI mean, I'm me, so I want to write Clojure. I haven't tried ClojureScript -> clasp to see if I can use ClojureScript. Does Google Apps Script document exactly what the runtime is? It looks like Rhino from some of the failure modes, but I don't know the exact modern JS features it supports. The huge benefit to GAS IMO is that creds never hit my disk.