使用 Microsoft Graph API 获取更改通知Use the Microsoft Graph API to get change notifications

Microsoft Graph REST API 使用 webhook 机制来将通知传递到客户端。The Microsoft Graph REST API uses a webhook mechanism to deliver notifications to clients. 客户端是配置其自己的 URL,以接收通知的 web 服务。A client is a web service that configures its own URL to receive notifications. 客户端应用程序使用通知更新时更改其状态。Client apps use notifications to update their state upon changes. 有关详细信息,包括如何订阅和处理传入通知,请参阅设置通知用户数据中的更改For more details, including how to subscribe to and handle incoming notifications, see Set up notifications for changes in user data.

使用 Microsoft Graph API,应用可以订阅以下资源的更改:Using the Microsoft Graph API, an app can subscribe to changes on the following resources:

  • 邮件Messages
  • 事件Events
  • 联系人Contacts
  • 用户Users
  • Groups
  • 组对话Group conversations
  • 在 OneDrive,包括与 SharePoint 网站关联的驱动器上共享的内容Content shared on OneDrive, including drives associated with SharePoint sites
  • 用户的个人 OneDrive 文件夹Users' personal OneDrive folders
  • 安全警报Security alerts

PermissionsPermissions

通常订阅操作需要拥有对资源的读取权限。例如,若要获取邮件通知,应用需要 Mail.Read 权限。创建订阅一文列出了各个资源类型所需的权限。下表列出了将 webhook 用于特定资源类型时应用可以请求的权限类型。In general, subscription operations require read permission to the resource. For example, to get notifications for messages, your app needs the Mail.Read permission. The create subscription article lists permissions needed for each resource type. The following table lists the types of permissions your app can request to use webhooks for specific resource types.

权限类型Permission type 支持的资源类型Supported resource types
委派 - 工作或学校帐户Delegated - work or school account 联系人对话驱动器事件、[消息][]、用户通知contact, conversation, drive, event, group, message, user, alert
委派 - 个人 Microsoft 帐户Delegated - personal Microsoft account 联系人驱动器事件、[消息][]contact, drive, event, message
应用程序Application 联系人对话驱动器事件、[消息][]、用户通知contact, conversation, drive, event, group, message, user, alert

另请参阅See also