Search code examples
javascriptgoogle-signingoogle-admin-sdkservice-accountsgoogle-directory-api

How to retrieve groups and members data from G Suite Hosted Domain


I successfully implemented Google Sign-in button where I log in using Gmail accounts from a hosted domain (HD) of mine: with Javascript I retrieve user's data, but the only infos about his/her HD is just the name (by using getHostedDomain()).

So I made a Service Account in order to get more infos about my HD (using Python API): by using HD name, I retrieve groups and members of the HD.

So far so good, but the process of information collection is not one: it is splitted in two different files executed at different times. For now, I sign-in with a Gmail account on a web page and I take note of the HD returned to which the logged user belongs; then I run my Python script in a terminal that examines the given HD name in order to retrieve groups and members.

I'm trying to implement a single execution collector where only a file is executed and possibly only one language is used: the web page is the file I cannot give up since I'd like to offer Google Sign-in, so I'm trying to access other HD infos (besides its name) from the web page with Javascript, without using my other Python script.

Is it possible to retrieve everything only using Javascript?


Solution

  • I think what you are looking for is to retrieve all groups for a domain or the account. Also to retrieve the data you needed for a specific user, you can use the method Users: get.