7
votes

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.

2

2 Answers

9
votes

[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

3
votes

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);
    ...
}