Hello,
We are using the certificate flow to authenticate with Sharepoint and create a ctx object to run queries. Once we create the ctx object the script needs to run thousands of queries, which can take over an hour to complete. After an hour the Sharepoint token expires and we get 401 errors on any subsequent api requests.
What is the best way to refresh the token? Should we get a new ctx object for each execute_query()? Or is there a another way to refresh the token with the existing ctx?
Sample auth code:
site_url = "https://www.sharepoint.com/sites/oursite
cert_settings = {
'tenant': 'yyyy',
'client_id': 'cccc',
'thumbprint': "tttt",
'cert_path': 'sharepoint.pem'
}
ctx = ClientContext(site_url).with_client_certificate(**cert_settings)
The script will successfully execute queries for an hour, but after an hour the token expires and we get the following exception:
401 Client Error: Unauthorized for url: https://www.sharepoint.com/sites/oursite
Hello,
We are using the certificate flow to authenticate with Sharepoint and create a ctx object to run queries. Once we create the ctx object the script needs to run thousands of queries, which can take over an hour to complete. After an hour the Sharepoint token expires and we get 401 errors on any subsequent api requests.
What is the best way to refresh the token? Should we get a new ctx object for each execute_query()? Or is there a another way to refresh the token with the existing ctx?
Sample auth code:
The script will successfully execute queries for an hour, but after an hour the token expires and we get the following exception:
401 Client Error: Unauthorized for url: https://www.sharepoint.com/sites/oursite