Google API: list the groups the logged-in user belongs to
Asked Answered
A

0

7

i have created an oauth2 workflow that correctly logs me in.

my scopes are:

when i go through the authorization process, it lists "View and manage your Google Groups" which i would assume means i can get a list of the google groups i am a part of. however, i cannot figure out where to send a request to get this info.

sending a GET request to the /admin/directory/v1/groups?userKey=userkey endpoint returns a 403 insufficient scope. but if i add to the scopes:

and then hit the same endpoint, i receive a 403 not authorized because i am not an admin on this system. (nor should i be)

I need to be able to get the list of groups for the user during the login process, not just if the logged in user is admin. This appears to be possible via an Apps Script library that has a read only accessor for Groups Service. I need an equivalent api endpoint. Does this exist? I cannot seem to find any documentation for any groups access outside of the admin sdk.

also, if i hit https://www.googleapis.com/auth/groups?userKey=userkey i just get the response "groups" so that's nice...

related/maybe duplicate of:

but the suggestion here points to App Script, not api

Amphibrach answered 22/7, 2020 at 21:11 Comment(2)
I have similar issue. endpoint for admin view groups is working, since i am checking that email address belongs to owned domain, e.g. [email protected] has domain example.org. Problem is that some users cannot pass authorization_token. I think it is related to those users not being admins on domain I use.Ishmael
Also, to answer that question for groups endpoint, it is this one googleapis.com/admin/directory/v1/groups?userKey={}&key={}, where key is API secret.Ishmael

© 2022 - 2024 — McMap. All rights reserved.