@@ -189,7 +189,7 @@ Usage
189189import adal
190190from office365.graph_client import GraphClient
191191
192- def acquire_token ():
192+ def acquire_token_func ():
193193 authority_url = ' https://login.microsoftonline.com/{tenant_id_or_name} '
194194 auth_ctx = adal.AuthenticationContext(authority_url)
195195 token = auth_ctx.acquire_token_with_client_credentials(
@@ -211,7 +211,7 @@ The example demonstrates how to send an email via [Microsoft Graph endpoint](htt
211211``` python
212212from office365.graph_client import GraphClient
213213
214- client = GraphClient(acquire_token )
214+ client = GraphClient(acquire_token_func )
215215
216216message_json = {
217217 " Message" : {
@@ -232,8 +232,7 @@ message_json = {
232232}
233233
234234235- client.users[login_name].send_mail(message_json)
236- client.execute_query()
235+ client.users[login_name].send_mail(message_json).execute_query()
237236```
238237
239238
@@ -251,7 +250,7 @@ is used to obtain token
251250``` python
252251import msal
253252
254- def acquire_token ():
253+ def acquire_token_func ():
255254 """
256255 Acquire token via MSAL
257256 """
@@ -279,10 +278,8 @@ which corresponds to [`list available drives` endpoint](https://docs.microsoft.c
279278from office365.graph_client import GraphClient
280279
281280tenant_name = " contoso.onmicrosoft.com"
282- client = GraphClient(acquire_token)
283- drives = client.drives
284- client.load(drives)
285- client.execute_query()
281+ client = GraphClient(acquire_token_func)
282+ drives = client.drives.get().execute_query()
286283for drive in drives:
287284 print (" Drive url: {0} " .format(drive.web_url))
288285```
@@ -292,12 +289,9 @@ for drive in drives:
292289
293290``` python
294291from office365.graph_client import GraphClient
295- client = GraphClient(acquire_token )
292+ client = GraphClient(acquire_token_func )
296293# retrieve drive properties
297- drive = client.users[" {user_id_or_principal_name} " ].drive
298- client.load(drive)
299- client.execute_query()
300-
294+ drive = client.users[" {user_id_or_principal_name} " ].drive.get().execute_query()
301295# download files from OneDrive into local folder
302296with tempfile.TemporaryDirectory() as path:
303297 download_files(drive.root, path)
@@ -307,15 +301,12 @@ where
307301
308302``` python
309303def download_files (remote_folder , local_path ):
310- drive_items = remote_folder.children
311- client.load(drive_items)
312- client.execute_query()
304+ drive_items = remote_folder.children.get().execute_query()
313305 for drive_item in drive_items:
314306 if not drive_item.file.is_server_object_null: # is file?
315307 # download file content
316308 with open (os.path.join(local_path, drive_item.name), ' wb' ) as local_file:
317- drive_item.download(local_file)
318- client.execute_query()
309+ drive_item.download(local_file).execute_query()
319310```
320311
321312
@@ -339,9 +330,8 @@ which corresponds to [`Create team` endpoint](https://docs.microsoft.com/en-us/g
339330``` python
340331from office365.graph_client import GraphClient
341332tenant_name = " contoso.onmicrosoft.com"
342- client = GraphClient(tenant_name, acquire_token)
343- new_team = client.groups[" {group_id} " ].add_team()
344- client.execute_query()
333+ client = GraphClient(tenant_name, acquire_token_func)
334+ new_team = client.groups[" {group_id} " ].add_team().execute_query_retry()
345335```
346336
347337
0 commit comments