Question

I have a webapp, and I want to tell if the currently-logged-in user is a member, manager, or owner of a specific Google Group (the same information that you could find by clicking on "members" from a group page). Ideally, it would also be nice to list all members, managers, and owners of the group as well.

The Members API (https://developers.google.com/admin-sdk/directory/v1/reference/members/list) seems promising, but when I try it in the API explorer, I get Not Authorized to access this resource/api errors even when I have provided OAuth permission. I can see the list of members using the Google Groups website, so it would appear that I have permission, but I am not the administrator of the Google Apps domain.

Any idea what I might be doing wrong? Thanks!

Was it helpful?

Solution

Any of the API calls in the Admin SDK require the authorising user to be an administrator of the domain they are being called against. You'll need to use an admin account to get a successful response.

OTHER TIPS

There is an API method to get the members that belong to a specific group. See the documentation here:

https://developers.google.com/admin-sdk/directory/v1/guides/manage-group-members#get_all_members

You could use GroupsApp to get a list of members of the group, providing you have access to view members of the group. Your best bet would be to set the options of the group to allow anyone to view members.

Then you could use Session.getActiveUser() and check if the name is in the list. All this can be done from with in the GAS of your webapp with no need fo APIs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top