-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathwith_app_only.py
More file actions
30 lines (20 loc) · 989 Bytes
/
Copy pathwith_app_only.py
File metadata and controls
30 lines (20 loc) · 989 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Connect to SharePoint using ACS App-Only principal (client credentials).
⚠️ DEPRECATED: Azure Access Control Service (ACS) is being retired.
ACS stopped working for new tenants on Nov 1, 2024, and will be fully
retired on April 2, 2026. Use Azure AD certificate auth instead.
This method is still relevant for SharePoint on-premises.
See https://learn.microsoft.com/en-us/sharepoint/dev/solution-guidance/security-apponly-azureacs
"""
import argparse
from office365.sharepoint.client_context import ClientContext
from tests.settings import cert_path, cert_thumbprint, client_id, site_url, tenant
def main():
argparse.ArgumentParser(description="Connect to SharePoint with client credentials").parse_args()
ctx = ClientContext(site_url).with_client_certificate(
tenant, client_id=client_id, thumbprint=cert_thumbprint, cert_path=cert_path
)
target_web = ctx.web.get().execute_query()
print(target_web.url)
if __name__ == "__main__":
main()