I want to get all my groups but I am not an admin
I know how to fetch groups if I am admin. But if not - I don't understand. Also I can see its via website
My steps:
- I do auth with Google and with scope
[
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/groups",
]
I fetch groups by GET. Url:
"https://admin.googleapis.com/admin/directory/v1/groups?domain=konstructly.com"I get the next problem:
{
"error": {
"code": 403,
"message": "Not Authorized to access this resource/api",
"errors": [
{
"message": "Not Authorized to access this resource/api",
"domain": "global",
"reason": "forbidden"
}
]
}
}
My question
How can I get my Google Groups via Google API?
I tried:
- Auth with scope
[
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/groups",
]
- GET
"https://admin.googleapis.com/admin/directory/v1/groups?domain=konstructly.com"
Expectation: List of my groups
Actual result:
{
"error": {
"code": 403,
"message": "Not Authorized to access this resource/api",
"errors": [
{
"message": "Not Authorized to access this resource/api",
"domain": "global",
"reason": "forbidden"
}
]
}
}
Instead of using the Google Workspace Admin SDK, use the Groups Service from Google Apps Script, more specifically GroupsApp.getGroups()