无法在Microsoft Graph API中使用开放扩展名获取事件 [英] Can't get events with open extension in Microsoft Graph API

查看:38
本文介绍了无法在Microsoft Graph API中使用开放扩展名获取事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过Graph API中的共享邮箱创建了一个事件.

I created an event through a shared mailbox in Graph API.

https://graph.microsoft.com/v1.0/users/{shared-user-id}/calendars/{shared-calendar-id}/events

{
  "subject": "New Event Test",
  "body": {
    "contentType": "HTML",
    "content": "Mail FLow Test"
  },
  "start": {
      "dateTime": "2021-01-29T12:00:00",
      "timeZone": "Eastern Standard Time"
  },
  "end": {
      "dateTime": "2021-01-30T14:00:00",
      "timeZone": "Eastern Standard Time"
  },
  "attendees": [
    {
      "emailAddress": {
            "address":"calendar@contoso.com",
            "name": "Calendar Organizer"
        },
        "type": "required"
    }
  ]
}

这将成功创建一个事件,然后,我使用开放扩展名对该事件进行了扩展数据修补.

This creates an event successfully, and after that, I patched this event with extended data using open extension.

https://graph.microsoft.com/v1.0/users/{user-id}/calendars/{calendar-id}/events/{just-created-event-id}

{
  "extensions": [
        {
          "@odata.type": "microsoft.graph.openTypeExtension",
          "extensionName": "Com.Contoso.Events",
          "courseId": 22,
          "materialId": 75,
          "courseType": "video"
        }
      ]
}

这似乎行不通.此响应访问被拒绝.

This seems not to work. This responses Access is denied.

https://graph.microsoft.com/v1.0/users/{shared-user-id}/calendars/{shared-calendar-id}/events?$expand=extensions($filter=id eq 'Microsoft.OutlookServices.OpenTypeExtension.Com.Contoso.Events')

它以错误消息拒绝访问"来响应 ErrorAccessDenided .检查凭据,然后重试".但是,如果我在不扩展扩展名的情况下尝试这样做,那么它将起作用.

It responses ErrorAccessDenided with error message "Access is denied. Check credentials and try again". But if I try this without expanding extensions, then it works.

我什至无法创建事件,因为它以相同的错误响应并且消息访问被拒绝".检查凭据,然后重试",因此我在Azure AD中添加了API权限 MailboxSettings.ReadWrite ,该功能通过共享邮箱创建了事件.

I couldn't even to create an event because it responded with the same error and message "Access is denied. Check credentials and try again", so I added an API permission MailboxSettings.ReadWrite in my Azure AD that made work an event creation through the shared mailbox.

为什么我可以创建或获取事件但不能添加或扩展扩展的原因是什么?

What is the reason why I can create or get events but not add or expand extensions?

推荐答案

在此处移动我的评论,以便将此问题视为已解决.

Move my comment here so that this issue is treated as answered.

您使用的方法不正确.请参考此示例以创建打开的扩展程序.

The method you are using is incorrect. Please refer to this sample to create the open extension.

但是根据我的测试,我们不能使用管理员(或委派用户或共享邮箱成员)来创建共享邮箱的扩展名(即使我添加了 Calendars.Readwrite.Shared >许可).遇到错误时,它将显示403错误.

But based on my test, we cannot use an admin (or a delegated user or a shared mailbox member) to create the extension for the shared mailbox (Even if I have added Calendars.Readwrite.Shared permission). It will give 403 error as you have encountered.

当我使用共享邮箱用户登录时,它可以为其自己创建打开的扩展名.

When I sign in with the shared mailbox user, it can create the open extension for itself.

因此结论是:当我们使用委派权限(用户令牌)时,我们只能为当前登录用户本人创建一个开放扩展.

So the conclusion is: when we use delegated permissions (user token), we can only create an open extension for the currently logged in user himself.

这篇关于无法在Microsoft Graph API中使用开放扩展名获取事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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