-
-
Notifications
You must be signed in to change notification settings - Fork 370
Expand file tree
/
Copy pathlist_groups.py
More file actions
18 lines (15 loc) · 624 Bytes
/
Copy pathlist_groups.py
File metadata and controls
18 lines (15 loc) · 624 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""Demonstrates how to list all site groups.
Official documentation: https://learn.microsoft.com/en-us/sharepoint/dev/apis/rest-api/csom/group
"""
from office365.sharepoint.client_context import ClientContext
from tests import test_client_id, test_password, test_site_url, test_tenant, test_username
ctx = ClientContext(test_site_url).with_username_and_password(
tenant=test_tenant,
client_id=test_client_id,
username=test_username,
password=test_password,
)
groups = ctx.web.site_groups.get().execute_query()
for g in groups:
print(f" {g.title} (ID: {g.id})")
print(f"Total: {len(groups)} groups")