Outlook - 阅读其他用户的日历

Ga *_*chi 8 android ms-office outlook-calendar office365 outlook-restapi

我正在开发基于Outlook-SDK-Android的Android应用程序.该应用程序与Outlook Calendar REST API进行对话,以检索,预订和删除事件(请参阅此处此处的代码示例).现在我需要阅读其他人的日历,并且我已经向其他用户提供了具有委托访问权限(作者权限级别)的Office365帐户.

我已使用新门户网站上提供的帐户注册了我的应用.在我的应用程序中,我使用范围" https://outlook.office.com/Calendars.ReadWrite ".(范围在com.microsoft.aad.adal.AuthenticationContext.acquireToken()中用于初始化Android Outlook ClientOffice REST客户端,这是由orc-for-android提供的共享客户端堆栈)

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

{
  "error": {
    "code": "ErrorAccessDenied",
    "message": "Access is denied. Check credentials and try again."
  }
}
Run Code Online (Sandbox Code Playgroud)

有帮助吗?

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

outlookClient.getUsers()
             .getById("meetingRoom@company.com")
             .getCalendarView()
Run Code Online (Sandbox Code Playgroud)

更新:

似乎正在进行的工作将允许此方案,如下所述:Office 365 REST API - 访问会议室日历

因此,如果在这方面取得进展,我可以在不使用" 管理服务应用程序 "的情况下实现我的目标吗?(请参阅Office 365 API或Azure AD Graph API - 获取某些其他日历)

我可以使用此处建议的基本身份验证吗?

Fei*_*SFT 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);
}
Run Code Online (Sandbox Code Playgroud)

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

https://officespdev.uservoice.com/