-
-
Notifications
You must be signed in to change notification settings - Fork 368
Expand file tree
/
Copy pathgrant_to_web.py
More file actions
18 lines (15 loc) · 676 Bytes
/
Copy pathgrant_to_web.py
File metadata and controls
18 lines (15 loc) · 676 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
"""
Grant a user access to a SharePoint web/site.
https://learn.microsoft.com/en-us/sharepoint/dev/apis/permissions-api-reference
"""
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.sharing.role_type import RoleType
from tests import test_client_id, test_password, test_site_url, test_tenant, test_user_principal_name, 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,
)
result = ctx.web.add_role_assignment(test_user_principal_name, RoleType.Contributor).execute_query()
print("Access granted")