python-o365
python-o365 copied to clipboard
Add support for the `OrderDateTime` field in ToDo tasks
Hey there! I'm a user of O365-HomeAssistant
looking to synchronise and view task lists.
I'd like the queried lists to match the sorting I've set in the app, but as I understand it, no public API exposes this data.
After some research and digging, I've found this endpoint: https://outlook.office.com/todob2/api/v1/taskfolders/{id}/tasks
Sample response
I've trimmed some data out here, and replaced it with [...]
.
{
"DeltaLink": "[...]",
"Value": [
{
"Body": {
"Content": "\r\n",
"ContentType": "Text"
},
"BodyLastModifiedTime": null,
"DueDate": null,
"StartDateTime": null,
"ChangeKey": "[...]",
"CommittedDay": null,
"CommittedOrder": null,
"CompletedDateTime": null,
"CreatedDateTime": "2023-05-05T16:47:08.5291536Z",
"CreatedWithLocalId": "[...]",
"DueDateTime": null,
"Id": "[...]",
"UncommittedDue": false,
"IsIgnored": false,
"IsImported": false,
"IsReminderOn": false,
"LastModifiedDateTime": "2023-05-05T16:52:09.6355655Z",
"OrderDateTime": "2023-04-26T19:24:20.4660000Z",
"ParentFolderId": "[...]",
"PostponedDay": null,
"Recurrence": null,
"ReminderDateTime": null,
"Status": "NotStarted",
"Subject": "[...]",
"Source": null,
"CreatedByRequestId": "[...]",
"AllExtensions": null,
"Importance": "Normal",
"CreatedByUser": {
"Id": "[...]",
"PrincipalName": null,
"DisplayName": null,
"SmtpAddress": null
},
"CompletedByUser": null,
"Categories": [],
"Sensitivity": "Normal"
},
{
"Body": {
"Content": "\r\n",
"ContentType": "Text"
},
"BodyLastModifiedTime": null,
"DueDate": "2023-05-07",
"StartDateTime": null,
"ChangeKey": "[...]",
"CommittedDay": null,
"CommittedOrder": null,
"CompletedDateTime": null,
"CreatedDateTime": "2023-05-04T18:00:14.1093677Z",
"CreatedWithLocalId": "[...]",
"DueDateTime": {
"DateTime": "2023-05-07T00:00:00.0000000",
"TimeZone": "UTC"
},
"Id": "[...]",
"UncommittedDue": false,
"IsIgnored": false,
"IsImported": false,
"IsReminderOn": false,
"LastModifiedDateTime": "2023-05-04T18:05:16.8002762Z",
"OrderDateTime": "2023-04-26T20:50:57.7160000Z",
"ParentFolderId": "[...]",
"PostponedDay": null,
"Recurrence": null,
"ReminderDateTime": null,
"Status": "NotStarted",
"Subject": "[...]",
"Source": null,
"CreatedByRequestId": "[...]",
"AllExtensions": null,
"Importance": "Normal",
"CreatedByUser": {
"Id": "[...]",
"PrincipalName": null,
"DisplayName": null,
"SmtpAddress": null
},
"CompletedByUser": null,
"Categories": [],
"Sensitivity": "Normal"
}
]
}
This endpoint exposes a field, OrderDateTime
, which, when sorted descending, matches the order set in the Microsoft ToDo apps.
I'd like to add support for this endpoint to the library, and while trying to figure out the right way to do that, I saw the two different implementations of the Tasks API, one for Outlook, and one for Graph. Obviously, this is an "Outlook only" feature; is implementing this feature in O365/tasks.py
the right approach? Should I do anything special, considering the undocumented and inherently fragile nature of implementing support for this?
The downstream project I'm doing this for uses the Account
class to access the Graph API (as it's Graph by default), but I'll need to use the Outlook version once I've implemented it here; is it possible to use both at once? AFAICT, as long as the right scopes are requested, there doesn't appear to be any reason why not. Both APIs are quite similar. Do you have any suggestions on how to do it without complicating authentication?
Thank you for the help!
this is an "Outlook only" feature; is implementing this feature in
O365/tasks.py
the right approach?
Yes
The downstream project I'm doing this for uses the
Account
class to access the Graph API (as it's Graph by default), but I'll need to use the Outlook version once I've implemented it here; is it possible to use both at once?
Yes!
Do you have any suggestions on how to do it without complicating authentication?
Just have two Accounts one with each protocol but both using the same auth token.