Outlook-阅读其他用户的日历 [英] Outlook - Read another user's calendar

查看:171
本文介绍了Outlook-阅读其他用户的日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在基于 Outlook-SDK-Android 开发一个Android应用.该应用程序与 Outlook日历REST API进行通信检索,预订和删除事件(请参见代码示例此处此处).现在,我需要阅读其他人的日历,并为我提供了具有代理访问权限的Office365帐户(

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.

我已使用提供的帐户在新门户上注册了我的应用.在我的应用程序中,我使用范围" https://outlook.office.com/Calendars.ReadWrite". (该范围在 com.microsoft.aad.adal.AuthenticationContext.acquireToken()中用于初始化 orc-for-android )

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)

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

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."
  }
}

有帮助吗?

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

Is it a limitation of the API? If so why is the following method invocation chain provided then?

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

更新:

似乎有正在进行的工作将允许这种情况发生,如下所示:

It seems like there are works in progress that will allow this scenario, as reported here: Office 365 REST API - Access meeting rooms calendars

因此,如果朝着这个方向取得了进展,我可以不使用"? (请参阅 Office 365 API或Azure AD Graph API-获取Elses日历)

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?

推荐答案

日历委托是Exchange的一项功能,Graph API和Outlook API不允许用户访问委托的日历. 当前,替代的解决方法是使用EWS.这是一个示例供您参考:

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,
            "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开发人员小组联系:

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/

这篇关于Outlook-阅读其他用户的日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆