使用 Microsoft Graph API 创建 webhook 时遇到问题 [英] Trouble creating a webhook using the Microsoft Graph API

查看:26
本文介绍了使用 Microsoft Graph API 创建 webhook 时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人幸运地创建了一个 webhook 来接收有关 O365 日历事件更改的通知?我在 Outlook Notifications REST API 上取得了成功,但在新的 Microsoft Graph API 上尝试同样的事情却是一段坎坷的旅程.

Has anyone had any luck creating a webhook to receive notifications about changes to O365 calendar's events? I've been successful with the Outlook Notifications REST API, but trying the same with the new Microsoft Graph API has been a bumpy ride.

我已经为 https://graph.microsoft.com 获得了一个仅限应用程序的令牌,我可以通常同时使用 v1.0 和 beta 端点服务就可以了.但是,当我尝试创建新订阅时(POST https://graph.microsoft.com/beta/subscriptions),我得到这个相当模糊的错误:

I've acquired an app-only token for https://graph.microsoft.com and I can generally use both v1.0- and beta-endpoint services just fine. However, when I try to create a new subscription (POST https://graph.microsoft.com/beta/subscriptions), I get this rather blurry error:

401 Unauthorized: {
  "error": {
    "code": "",
    "message": "Invalid security token.",
    "innerError": {
      "request-id": "c5a64878-e643-41be-b863-a598e05f38a4",
      "date": "2015-11-28T17:59:24"
    }
  }
}

我已为我的应用授予以下应用权限:Microsoft Graph - 读取所有用户的完整个人资料、读取目录数据读取所有邮箱中的日历.根据文档 Calendars.Read 需要权限.

I've given the following application permissions to my app: Microsoft Graph - Read all users' full profiles, Read directory data, and Read calendars in all mailboxes. According to the documentation Calendars.Read permission is required.

我想知道我做错了什么,或者可能是创建订阅服务无法正确处理仅限应用程序的令牌?

I wonder what I'm doing wrong or might it be that the create subscription service is unable to properly handle app-only token's?

解码后的令牌是:

{
 typ: "JWT",
 alg: "RS256",
 x5t: "MnC_VZcATfM5pOYiJHMba9goEKY",
 kid: "MnC_VZcATfM5pOYiJHMba9goEKY"
}.
{
 aud: "https://graph.microsoft.com/",
 iss: "https://sts.windows.net/58108de9-edf3-####-b20b-817520334d13/",
 iat: 1448814967,
 nbf: 1448814967,
 exp: 1448818867,
 appid: "5e80f22f-ff14-####-962a-2a9362a6057c",
 appidacr: "2",
 idp: "https://sts.windows.net/58108de9-edf3-####-b20b-817520334d13/",
 oid: "87b9064d-3dc7-####-9071-7a61b5b57840",
 roles: [
  "Calendars.Read",
  "Directory.Read.All",
  "User.Read.All"
 ],
 sub: "87b9064d-3dc7-####-9071-7a61b5b57840",
 tid: "58108de9-edf3-####-b20b-817520334d13",
 ver: "1.0"
}.

推荐答案

订阅现在是基于每个用户的,因此不能使用仅限应用的令牌创建它们.感谢您的反馈,我们将考虑增加对此方案的支持.

Subscriptions are on a per user basis right now, therefore they cannot be created using an app-only token. Thank you for the feedback we will look into adding support for this scenario.

这篇关于使用 Microsoft Graph API 创建 webhook 时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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