Skip to content

Commit e0148a9

Browse files
committed
Outlook client switch from outlook.office365.com into graph.microsoft.com
1 parent bc729a8 commit e0148a9

File tree

6 files changed

+33
-25
lines changed

6 files changed

+33
-25
lines changed

examples/settings.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os
22

33
user_credentials = os.environ['Office365_Python_Sdk_Credentials'].split(';')
4+
client_credentials = os.environ['Office365_Python_Sdk_ClientCredentials'].split(';')
45

56
settings = {
67
'url': 'https://mediadev88.sharepoint.com/',
@@ -12,6 +13,6 @@
1213
},
1314
'client_credentials': {
1415
'client_id': 'd4b2d51e-2d8e-4f08-8bce-961a7a435130',
15-
'client_secret': 'v+lDZaIvLTHRsZ8/opvurqneZnH/DKXls18MVyX+0BY=',
16+
'client_secret': client_credentials[1],
1617
}
1718
}

office365/outlookservices/contact.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ class Contact(Item):
66

77
@property
88
def contact_id(self):
9-
if self.is_property_available('Id'):
10-
return self.properties["Id"]
9+
if self.is_property_available('id'):
10+
return self.properties["id"]
1111
return None

office365/outlookservices/outlook_entity.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ def delete_object(self):
1818
@property
1919
def resource_path(self):
2020
orig_path = ClientObject.resource_path.fget(self)
21-
if self.is_property_available("Id") and orig_path is None:
21+
if self.is_property_available("id") and orig_path is None:
2222
return ResourcePathEntry(self.context,
2323
self._parent_collection.resource_path,
24-
self.properties["Id"])
24+
self.properties["id"])
2525
return orig_path
2626

office365/runtime/auth/oauth_token_provider.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, tenant, client_id, client_secret, user_name, password):
1717
self.client_secret = client_secret
1818
self.user_name = user_name
1919
self.password = password
20-
self.scope = 'user.read openid profile offline_access https://graph.microsoft.com/Contacts.ReadWrite'
20+
self.scope = 'user.read openid profile offline_access'
2121

2222
def acquire_token(self):
2323
try:

tests/test_outlook_calendar.py

+25-18
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,37 @@
33

44
class TestOutlookCalendar(OutlookClientTestCase):
55
def test1_create_event(self):
6-
event_info = {
7-
"Subject": "Discuss the Calendar REST API",
8-
"Body": {
9-
"ContentType": "HTML",
10-
"Content": "I think it will meet our requirements!"
6+
event_payload = {
7+
"subject": "Let's go for lunch",
8+
"body": {
9+
"contentType": "HTML",
10+
"content": "Does late morning work for you?"
1111
},
12-
"Start": "2014-02-02T18:00:00-08:00",
13-
"StartTimeZone": "Pacific Standard Time",
14-
"End": "2014-02-02T19:00:00-08:00",
15-
"EndTimeZone": "Pacific Standard Time",
16-
"Attendees": [
12+
"start": {
13+
"dateTime": "2017-04-15T12:00:00",
14+
"timeZone": "Pacific Standard Time"
15+
},
16+
"end": {
17+
"dateTime": "2017-04-15T14:00:00",
18+
"timeZone": "Pacific Standard Time"
19+
},
20+
"location": {
21+
"displayName": "Harry's Bar"
22+
},
23+
"attendees": [
1724
{
18-
"EmailAddress": {
19-
"Address": "janets@a830edad9050849NDA1.onmicrosoft.com",
20-
"Name": "Janet Schorr"
25+
"emailAddress": {
26+
"address": "samanthab@contoso.onmicrosoft.com",
27+
"name": "Samantha Booth"
2128
},
22-
"Type": "Required"
29+
"type": "required"
2330
}
2431
]
2532
}
2633

27-
event = self.client.me.events.add_from_json(event_info)
34+
event = self.client.me.events.add_from_json(event_payload)
2835
self.client.execute_query()
29-
self.assertIsNotNone(event.properties["Id"])
36+
self.assertIsNotNone(event.properties["id"])
3037

3138
def test2_get_events(self):
3239
events = self.client.me.events
@@ -41,7 +48,7 @@ def test3_update_event(self):
4148
if len(results) == 1:
4249
event = results[0]
4350
self.assertIsNotNone(event.properties["subject"])
44-
event.set_property("Subject", "Discuss the Calendar REST API (updated)")
51+
event.set_property("subject", "Discuss the Calendar REST API (updated)")
4552
event.update()
4653
self.client.execute_query()
4754

@@ -57,5 +64,5 @@ def test4_delete_event(self):
5764
events = self.client.me.events
5865
self.client.load(events)
5966
self.client.execute_query()
60-
results = [e for e in events if e.properties["Id"] == event.properties["Id"]]
67+
results = [e for e in events if e.properties["id"] == event.properties["id"]]
6168
self.assertEqual(len(results), 0)

tests/test_outlook_contacts.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ def test3_update_contact(self):
3939
self.client.execute_query()
4040
if len(results) == 1:
4141
contact = results[0]
42-
self.assertIsNotNone(contact.url)
42+
self.assertIsNotNone(contact.properties["id"])
4343
contact.set_property("department", "Media")
4444
contact.update()
4545
self.client.execute_query()

0 commit comments

Comments
 (0)