Outlook - 阅读其他用户的日历

时间:2016-03-13 22:16:50

标签: android ms-office office365 outlook-restapi outlook-calendar

我正在开发基于Outlook-SDK-Android的Android应用。该应用与Outlook Calendar REST API进行对话,以检索,预订和删除事件(请参阅代码示例herehere)。现在我需要阅读别人的日历,并且我已经向其他用户提供了一个Office365帐户,其中包含代理访问权限(author permission level)。

我已使用new portal上提供的帐户注册了我的应用。在我的应用程序中,我使用范围“https://outlook.office.com/Calendars.ReadWrite”。 (范围在 com.microsoft.aad.adal.AuthenticationContext.acquireToken()中用于初始化Office REST Client for Android OutlookClient,orc-for-android提供的共享客户端堆栈)

当我尝试阅读我有委托访问权限的另一个用户日历时,我只收到了403响应:

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

任何帮助?

这是API的限制吗?如果是这样,为什么提供以下方法调用链呢?

outlookClient.getUsers()
             .getById("meetingRoom@company.com")
             .getCalendarView()

更新:

似乎有正在进行中将允许此方案,如下所示:Office 365 REST API - Access meeting rooms calendars

因此,如果已朝这个方向取得进展,我可以实现我的目标而不使用“admin service app吗? (见Office 365 API or Azure AD Graph API - Get Someone Elses Calendar

我可以按建议here使用基本身份验证吗?

2 个答案:

答案 0 :(得分:4)

日历委派是Exchange的一项功能,Graph API和Outlook API不允许用户访问委派的日历。 目前,替代解决方法可以使用EWS。以下是供您参考的示例:

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,
            "fx@msdnofficedev.onmicrosoft.com"),
            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);
}

如果您希望Outlook和Graph API支持此功能,您可以尝试通过以下链接与Office开发人员团队联系:

https://officespdev.uservoice.com/

答案 1 :(得分:1)

FindMeetingTimes目前正在预览中!要查看详细信息,请使用此链接,然后将其更改为查看文章的Beta版本(主栏右上角):https://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations#Findmeetingtimespreview

以下文章详述,但请使用链接获取最新信息:

查找会议时间(预览)

根据组织者和与会者的可用性以及时间或地点限制查找会议时间建议。

此操作目前处于预览状态,仅在测试版中提供。

所有受支持的方案都使用FindMeetingTimes操作。 FindMeetingTimes接受在请求正文中指定为参数的约束,并检查组织者和与会者的主日历中的忙/闲状态。响应包括会议时间建议,每个建议被定义为MeetingTimeCandidate,与会者平均有50%或更高的机会参加。

相关问题