Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Outlook - Read another user's calendar

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?

like image 801
Gabe Avatar asked Mar 13 '16 22:03

Gabe


People also ask

How do I view someone else's calendar?

On your computer, open Google Calendar. On the left click Search for people. Start typing someone's name and choose the person whose calendar you want to see. If their calendar is shared publicly or within your organization, you'll see their events on your calendar.

How do I view another user's calendar in another team?

Although you can't check the calendar of other team members in Microsoft Teams, your team can share their main Outlook calendar with the group. They can do that by using the sharing permissions of their Outlook calendars. All they need to do is open their calendars and hit the Share button.

Why can't I see other people's calendar in Outlook?

Resolution. To resolve this issue, go to your calendar, select the calendar tab, and click on the calendar permissions. The user will then be prompted to accept the changes. Click okay and the permissions should set accordingly.


1 Answers

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/

like image 104
Fei Xue - MSFT Avatar answered Sep 27 '22 15:09

Fei Xue - MSFT