Skip to content

Commit 99a9757

Browse files
authored
Merge pull request #219 from mustafaquraish/patch-1
Added code formatting to README
2 parents f169b8c + b376ed1 commit 99a9757

File tree

1 file changed

+21
-30
lines changed

1 file changed

+21
-30
lines changed

README.md

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -46,37 +46,31 @@ There are **two approaches** available to perform API queries:
4646

4747
1. `ClientContext class` - where you target SharePoint resources such as `Web`, `ListItem` and etc (recommended)
4848

49+
```python
50+
from office365.sharepoint.client_context import ClientContext
4951

50-
```
51-
52-
from office365.sharepoint.client_context import ClientContext
53-
54-
ctx = ClientContext(site_url).with_credentials(UserCredential(username, password))
55-
web = ctx.web
56-
ctx.load(web)
57-
ctx.execute_query()
58-
print "Web title: {0}".format(web.properties['Title'])
59-
```
60-
or alternatively via method chaining (a.k.a Fluent Interface):
61-
52+
ctx = ClientContext(site_url).with_credentials(UserCredential(username, password))
53+
web = ctx.web
54+
ctx.load(web)
55+
ctx.execute_query()
56+
print "Web title: {0}".format(web.properties['Title'])
6257
```
58+
or alternatively via method chaining (a.k.a Fluent Interface):
6359

64-
from office365.sharepoint.client_context import ClientContext
65-
66-
ctx = ClientContext(site_url).with_credentials(UserCredential(username, password))
67-
web = ctx.web.load().execute_query()
68-
print "Web title: {0}".format(web.properties['Title'])
69-
```
60+
```python
61+
from office365.sharepoint.client_context import ClientContext
7062

63+
ctx = ClientContext(site_url).with_credentials(UserCredential(username, password))
64+
web = ctx.web.load().execute_query()
65+
print "Web title: {0}".format(web.properties['Title'])
66+
```
7167

7268

7369
2. `RequestOptions class` - where you construct REST queries (and no model is involved)
7470

7571
The example demonstrates how to read `Web` properties:
7672

77-
78-
79-
```
73+
```python
8074
import json
8175
from office365.runtime.auth.UserCredential import UserCredential
8276
from office365.runtime.http.request_options import RequestOptions
@@ -88,7 +82,6 @@ response = ctx.execute_request_direct(request)
8882
json = json.loads(response.content)
8983
web_title = json['d']['Title']
9084
print("Web title: {0}".format(web_title))
91-
9285
```
9386

9487

@@ -119,7 +112,7 @@ The example demonstrates how to send an email via [Microsoft Graph endpoint](htt
119112

120113
> Note: access token is getting acquired via [Client Credential flow](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow)
121114
122-
```
115+
```python
123116
def get_token(auth_ctx):
124117
token = auth_ctx.acquire_token_with_client_credentials(
125118
"https://graph.microsoft.com",
@@ -175,7 +168,7 @@ which corresponds to [`list available drives` endpoint](https://docs.microsoft.c
175168

176169
> Note: access token is getting acquired via [Client Credential flow](https://docs.microsoft.com/en-us/azure/active-directory/develop/v2-oauth2-client-creds-grant-flow)
177170
178-
```
171+
```python
179172
def get_token(auth_ctx):
180173
"""Acquire token via client credential flow (ADAL Python library is utilized)"""
181174
token = auth_ctx.acquire_token_with_client_credentials(
@@ -197,7 +190,7 @@ for drive in drives:
197190

198191
##### Example: download the contents of a DriveItem(folder facet)
199192

200-
```
193+
```python
201194
# retrieve drive properties (source)
202195
drive = client.users[user_id_or_principal_name].drive
203196
client.load(drive)
@@ -210,7 +203,7 @@ with tempfile.TemporaryDirectory() as path:
210203

211204
where
212205

213-
```
206+
```python
214207
def download_files(remote_folder, local_path):
215208
drive_items = remote_folder.children
216209
client.load(drive_items)
@@ -241,18 +234,16 @@ library is utilized to authenticate users to Active Directory (AD) and obtain to
241234
The example demonstrates how create a new team under a group
242235
which corresponds to [`Create team` endpoint](https://docs.microsoft.com/en-us/graph/api/team-put-teams?view=graph-rest-1.0&tabs=http)
243236

244-
```
245-
237+
```python
246238
tenant_name = "contoso.onmicrosoft.com"
247239
client = GraphClient(tenant_name, get_token)
248240
new_team = client.groups[group_id].add_team()
249241
client.execute_query()
250-
251242
```
252243

253244
where
254245

255-
```
246+
```python
256247
def get_token(auth_ctx):
257248
"""Acquire token via client credential flow (ADAL Python library is utilized)
258249
:type auth_ctx: adal.AuthenticationContext

0 commit comments

Comments
 (0)