android - Outlook - 阅读其他用户的日历

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

我正在开发基于 Outlook-SDK-Android 的 Android 应用程序.该应用程序与 Outlook Calendar REST API 对话检索、预订和删除事件(参见代码示例 herehere )。现在我需要阅读其他人的日历,我已经获得了一个 Office365 帐户,该帐户对其他用户具有委托(delegate)访问权限 ( 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 提供的共享客户端堆栈)

当我尝试读取另一个我具有委托(delegate)访问权限的用户的日历时,我只收到 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

最佳答案

日历委托(delegate)是 Exchange 的一项功能,Graph API 和 Outlook API 不允许用户访问委托(delegate)日历。 目前,替代解决方法是使用 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/

关于android - Outlook - 阅读其他用户的日历,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35976578/

相关文章:

java - Android 不会根据不同的屏幕布局调整大小

android - Nativescript 在 debug.apk 上构建发布 apk 成功时失败

android - ViewPager 的自定义页面可绘制对象

.net - 选择 Microsoft Office 主互操作程序集版本

charts - POWER BI - 根据值显示/隐藏图表

office365 - 仅在 Web 版办公产品上启用 Office 加载项

c# - 使用 Microsoft Graph .NET 客户端库分配经理

android - fragment 不刷新其内容

c# - 如何检测安装的 MS-Office 版本?

c# - 如何从 Word 文档中获取主题和标题(无需打开)?