Access to other user's calendar in Office 365 API
Asked Answered
S

2

7

I'm building a WPF-app that's doing a summary of several user's calendar in the organization. The Company is using Office 365 so I thought that the Office 365 API would be the best way to go.

I've managed to access my own calendar, but I don't know how to access my colleagues' calendars. Is it possible? I also need to list the GAL in order to pick which users I wolud like to include in the summary.

Socman answered 13/9, 2014 at 7:30 Comment(0)
A
9

[UPDATE] Service account support is available now for REST APIs. Please see Building Daemon or Service Apps with Office 365 Mail, Calendar, and Contacts APIs (OAuth2 client credential flow) for more info.

Thanks for your question and interest in Office 365 APIs! Currently, you can use the Office 365 API to access the authenticated user's calendar but not another user's calendar. Enabling a service account to be authorized to access mail/calendar/contacts of multiple users within an organization or the entire organization is on our roadmap and is prioritized pretty high, so stay tuned.

In the mean time, you can use Exchange Web Services (EWS) Managed API to implement your application. However, with EWS app impersonation, the service account has read/write access to the user's entire mailbox, and not just the calendar. Once we add support for service accounts in Office 365 API, you will be able to use OAuth and scope down the access of the app to only read a user's calendar.

Here are a few links explaining how EWS app impersonation works.

Please let me know if you have any questions or need more info.

Thanks,

Venkat

Ancier answered 14/9, 2014 at 0:28 Comment(7)
Any updates with the API's access to another user's calendar?Principal
@venkat any updates on this? are we able to access other user's calendar?Blackcap
Not yet, sorry. This is still being worked on. Thanks.Ancier
Is there any update on the OAuth way of scoping access? Would be pretty nifty to assure useres that an Application verifiably only accesses their Calendar OR Mail OR Contacs (or whatever conbimantion)Alexis
Will it (or similar fine grained access definitions) be avialable for accesing in an On-Premise Exchange via EWS?Alexis
@ivo You can scope app-only access to specific permissions such as Calendar.Read or Mail.ReadWrite. This is already supported. Let me know if you are having trouble setting this. No, the fine-grained access isn't available for accessing on-premises Exchange via EWS, since EWS only supports full-mailbox access.Ancier
@venkat I would have been in need of this kind of access for EWS due to privacy reasons. So EWS is a no go atm.Alexis
P
3

Yes, it is possible with Basic Authentication (but not with OAuth2). Plus your account must have Read access to your colleagues' calendars (can be done by an admin by setting mailbox folder permissions).

var authClearText = string.Format("{0}:{1}", yourEmail, yourPassword);
var authEncoded = Convert.ToBase64String(Encoding.Default.GetBytes(authClearText));
var authHeaderValue = "Basic " + authEncoded;

using (var httpClient = new HttpClient())
{
    httpClient.DefaultRequestHeaders.Add("Authorization", authHeaderValue);
    ...
}
Pardoes answered 19/9, 2014 at 21:10 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.