8
votes

I'm developing an Android App based on Outlook-SDK-Android. The App talks with Outlook Calendar REST API to retrieve, book and delete events (see code examples here and here). Now I need to read someone else's calendar and I've been provided an Office365 account with delegate access (author permission level) towards other users.

I've registered my app using the provided account on the new portal. In my App I use the scope "https://outlook.office.com/Calendars.ReadWrite". (The scope is used in com.microsoft.aad.adal.AuthenticationContext.acquireToken() to initialize an Office REST Client for Android OutlookClient, a shared client stack provided by orc-for-android)

When I try to read another user's calendar on which I have delegate access I just receive back a 403 response:

{
  "error": {
    "code": "ErrorAccessDenied",
    "message": "Access is denied. Check credentials and try again."
  }
}

Any help?

Is it a limitation of the API? If so why is the following method invocation chain provided then?

outlookClient.getUsers()
             .getById("[email protected]")
             .getCalendarView()

UPDATE:

It seems like there are works in progress that will allow this scenario, as reported here: Office 365 REST API - Access meeting rooms calendars

So if progress in that direction has been made can I achieve my goal without using an "admin service app"? (see Office 365 API or Azure AD Graph API - Get Someone Elses Calendar)

Can I use basic authentication as suggested here?

2

2 Answers

4
votes

Calendar delegation is a feature of Exchange, the Graph API and Outlook API do not allow the user to access the delegated calendar. Currently, the alternative workaround could be use the EWS. And here is an sample for your reference:

static void DelegateAccessSearchWithFilter(ExchangeService service, SearchFilter filter)
{
    // Limit the result set to 10 items.
    ItemView view = new ItemView(10);

    view.PropertySet = new PropertySet(ItemSchema.Subject,
                                       ItemSchema.DateTimeReceived,
                                       EmailMessageSchema.IsRead);

    // Item searches do not support deep traversal.
    view.Traversal = ItemTraversal.Shallow;

    // Define the sort order.
    view.OrderBy.Add(ItemSchema.DateTimeReceived, SortDirection.Descending);

    try
    {
        // Call FindItems to find matching calendar items. 
        // The FindItems parameters must denote the mailbox owner,
        // mailbox, and Calendar folder.
        // This method call results in a FindItem call to EWS.
        FindItemsResults<Item> results = service.FindItems(
        new FolderId(WellKnownFolderName.Calendar,
            "[email protected]"),
            filter,
            view);

        foreach (Item item in results.Items)
        {
            Console.WriteLine("Subject: {0}", item.Subject);
            Console.WriteLine("Id: {0}", item.Id.ToString());
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine("Exception while enumerating results: { 0}", ex.Message);
    }
}

private static void GetDeligateCalendar(string mailAddress, string password)
{
    ExchangeService service = new ExchangeService();

    service.Credentials = new WebCredentials(mailAddress, password);

    service.TraceEnabled = true;
    service.TraceFlags = TraceFlags.All;

    service.AutodiscoverUrl(mailAddress, RedirectionUrlValidationCallback);

    SearchFilter sf = new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(AppointmentSchema.Subject, "Discuss the Calendar REST API"));
    DelegateAccessSearchWithFilter(service, sf);
}

And if you want the Outlook and Graph API to support this feature, you can try to contact the Office developer team from link below:

https://officespdev.uservoice.com/

1
votes

FindMeetingTimes is currently in preview! To view the details, use this link and then change it to view the Beta version of the article (top right in the main column): https://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations#Findmeetingtimespreview

Details below from the article, but please use the link to get the latest:

Find meeting times (preview)

Find meeting time suggestions based on organizer and attendee availability, and time or location constraints.

This operation is currently in preview and available in only the beta version.

All the supported scenarios use the FindMeetingTimes action. FindMeetingTimes accepts constraints specified as parameters in the request body, and checks the free/busy status in the primary calendars of the organizer and attendees. The response includes meeting time suggestions, each of which is defined as a MeetingTimeCandidate, with attendees having on the average a confidence level of 50% chance or higher to attend.