Skip to content

Commit 1394511

Browse files
committed
Examples update & SharePoint model updates
1 parent 615211c commit 1394511

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+402
-103
lines changed

examples/onedrive/files/download.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88

99
from office365.graph_client import GraphClient
1010
from tests import test_client_id, test_password, test_tenant, test_username
11-
from tests.graph_case import acquire_token_by_username_password
1211

1312
client = GraphClient.with_username_and_password(
1413
test_tenant, test_client_id, test_username, test_password

examples/onedrive/files/send_sharing_invitation.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
from office365.graph_client import GraphClient
1212
from tests import test_client_id, test_password, test_tenant, test_username
13-
from tests.graph_case import acquire_token_by_username_password
1413

1514
file_name = "Financial Sample.xlsx"
1615
client = GraphClient.with_username_and_password(

examples/onedrive/folders/list_files.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
"""
55
from office365.graph_client import GraphClient
66
from tests import test_client_id, test_password, test_tenant, test_username
7-
from tests.graph_case import acquire_token_by_username_password
87

98
client = GraphClient.with_username_and_password(
109
test_tenant, test_client_id, test_username, test_password

examples/onenote/create_page.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
"""
66

77
from office365.graph_client import GraphClient
8-
from tests.graph_case import acquire_token_by_username_password
8+
from tests import test_client_id, test_password, test_tenant, test_username
99

10-
client = GraphClient(acquire_token_by_username_password)
10+
client = GraphClient.with_username_and_password(
11+
test_tenant, test_client_id, test_username, test_password
12+
)
1113

1214
files = {}
1315
with open("../data/Sample.html", "rb") as f, open(

examples/outlook/calendars/share_with.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@
77
"""
88
from office365.graph_client import GraphClient
99
from office365.outlook.calendar.role_type import CalendarRoleType
10-
from tests.graph_case import acquire_token_by_username_password
10+
from tests import test_client_id, test_password, test_tenant, test_username
1111

12-
client = GraphClient(acquire_token_by_username_password)
13-
my_cal = client.me.calendar
14-
cal_perm = my_cal.calendar_permissions.add(
12+
client = GraphClient.with_username_and_password(
13+
test_tenant, test_client_id, test_username, test_password
14+
)
15+
16+
cal_perm = client.me.calendar.calendar_permissions.add(
1517
"[email protected]", CalendarRoleType.read
1618
).execute_query()
1719
print(cal_perm)

examples/outlook/events/delete.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
"""
44

55
from office365.graph_client import GraphClient
6-
from tests.graph_case import acquire_token_by_username_password
6+
from tests import test_client_id, test_password, test_tenant, test_username
77

8-
client = GraphClient(acquire_token_by_username_password)
8+
client = GraphClient.with_username_and_password(
9+
test_tenant, test_client_id, test_username, test_password
10+
)
911
event_id = "--event id goes here--"
1012
event_to_del = client.me.calendar.events[event_id]
1113
event_to_del.delete_object().execute_query()

examples/outlook/events/list.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
https://learn.microsoft.com/en-us/graph/api/calendar-list-events?view=graph-rest-1.0
55
"""
66
from office365.graph_client import GraphClient
7-
from tests.graph_case import acquire_token_by_username_password
7+
from tests import test_client_id, test_password, test_tenant, test_username
88

9-
client = GraphClient(acquire_token_by_username_password)
9+
client = GraphClient.with_username_and_password(
10+
test_tenant, test_client_id, test_username, test_password
11+
)
1012
events = (
11-
client.me.calendar.events.get().top(100).select(["subject", "body"]).execute_query()
13+
client.me.calendar.events.get().top(10).select(["subject", "body"]).execute_query()
1214
)
1315
for event in events:
1416
print(event.subject)

examples/outlook/messages/create_draft_with_attachments.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44
import base64
55

66
from office365.graph_client import GraphClient
7-
from tests.graph_case import acquire_token_by_username_password
7+
from tests import test_client_id, test_password, test_tenant, test_username
88

99
with open(r"../../data/Sample.pdf", "rb") as f:
1010
content = base64.b64encode(f.read()).decode()
11-
client = GraphClient(acquire_token_by_username_password)
11+
client = GraphClient.with_username_and_password(
12+
test_tenant, test_client_id, test_username, test_password
13+
)
1214
client.me.messages.add(
1315
subject="Meet for lunch?",
1416
body="The new cafeteria is open.",

examples/outlook/messages/create_property.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@
88
import sys
99

1010
from office365.graph_client import GraphClient
11-
from tests.graph_case import acquire_token_by_username_password
11+
from tests import test_client_id, test_password, test_tenant, test_username
1212

13-
client = GraphClient(acquire_token_by_username_password)
13+
client = GraphClient.with_username_and_password(
14+
test_tenant, test_client_id, test_username, test_password
15+
)
1416
messages = client.me.messages.top(1).get().execute_query()
1517
if len(messages) == 0:
1618
sys.exit("No messages were found")

examples/outlook/messages/create_subscription.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
import datetime
77

88
from office365.graph_client import GraphClient
9-
from tests.graph_case import acquire_token_by_username_password
9+
from tests import test_client_id, test_password, test_tenant, test_username
1010

11-
client = GraphClient(acquire_token_by_username_password)
11+
client = GraphClient.with_username_and_password(
12+
test_tenant, test_client_id, test_username, test_password
13+
)
1214

1315
existing_subscriptions = client.subscriptions.get().execute_query()
1416

0 commit comments

Comments
 (0)