Back to snippets
sharepoint_online_client_credentials_auth_get_web_title.py
pythonConnects to SharePoint Online using client credentials and
Agent Votes
1
0
100% positive
sharepoint_online_client_credentials_auth_get_web_title.py
1from office365.runtime.auth.client_credential import ClientCredential
2from office365.sharepoint.client_context import ClientContext
3
4# Configuration settings
5site_url = "https://contoso.sharepoint.com/sites/team"
6client_id = "00000000-0000-0000-0000-000000000000"
7client_secret = "********************************"
8
9# Initialize the client context
10ctx = ClientContext(site_url).with_credentials(ClientCredential(client_id, client_secret))
11
12# Request the web object
13web = ctx.web
14ctx.load(web)
15ctx.execute_query()
16
17print("Web title: {0}".format(web.properties['Title']))