【问题标题】:Outlook - Read another user's calendarOutlook - 阅读其他用户的日历
【发布时间】:2016-06-28 20:15:56
【问题描述】:

我正在开发基于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的建议使用基本身份验证吗?

【问题讨论】:

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


    【解决方案1】:

    日历委托是 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/

    【讨论】:

    【解决方案2】:

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

    以下详情来自文章,但请使用链接获取最新消息:

    查找会议时间(预览)

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

    此操作目前处于预览阶段,仅在测试版中可用。

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

    【讨论】:

    • FindMeetingTimes 不允许我让其他用户开会,但只能安排可用时间。谢谢,还是有用的
    猜你喜欢
    • 1970-01-01
    • 2020-10-05
    • 2012-02-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-21
    • 1970-01-01
    相关资源
    最近更新 更多