google-api-nodejs-client icon indicating copy to clipboard operation
google-api-nodejs-client copied to clipboard

API to get Groups that a user belongs to?

Open joetito1 opened this issue 4 years ago • 1 comments

Hello - are there any APIs available to determine which groups a user belongs to? I'm having a hard time figuring out how to do this. Ideally, I would like to pass in the email address of a user and get back a list of groups.

Any help is appreciated!

joetito1 avatar Sep 30 '21 15:09 joetito1

@joetito1 As the documentation states. You can provide customer and userKey. The userKey will show you all groups that the user provided is a part of.

GET https://admin.googleapis.com/admin/directory/v1/groups?customer=abc123&[email protected]

If that doesn't work for some reason, then you can use the query method. Adding [email protected] to the query option will return all the groups he's a part of.

GET https://admin.googleapis.com/admin/directory/v1/groups?customer=abc123&[email protected]

OrKarstoft avatar Feb 17 '22 06:02 OrKarstoft

Also posting this thread for more reference: https://github.com/googleapis/google-api-nodejs-client/issues/2515

Thank you @OrKarstoft!

sofisl avatar Jan 19 '23 20:01 sofisl