未收到 Microsoft Graph 更改通知

And*_*sen 5 azure azure-active-directory microsoft-graph-api

我想订阅用户删除,以便每当在 Azure AD 中删除用户时,我们的应用程序都可以做出相应的反应。

这是我的订阅请求:

const now = new Date();
const threeDaysLater = new Date(now.getTime() + 3 * 24 * 58 * 60 * 1000);
request.post({
  auth: {
    bearer: {...},
  },
  headers: {
    Accept: 'application/json',
  },
  json: {
    changeType: 'updated,deleted',
    clientState: {...},
    expirationDateTime: threeDaysLater.toISOString(),
    notificationUrl: 'https://{...}.ngrok.io/api/azure/webhook',
    resource: 'users',
    latestSupportedTlsVersion: 'v1_2',
  },
  url: 'https://graph.microsoft.com/v1.0/subscriptions',
});
Run Code Online (Sandbox Code Playgroud)

发送此请求后,我会收到一个发送到 my 的请求notificationUrl,我会使用验证令牌对其进行响应。

然后我收到来自初始请求的以下响应:

{
  '@odata.context':
   'https://graph.microsoft.com/v1.0/$metadata#subscriptions/$entity',
  id: {...},
  resource: 'users',
  applicationId: {...},
  changeType: 'updated,deleted',
  clientState: {...},
  notificationUrl: 'https://{...}.ngrok.io/api/azure/webhook',
  expirationDateTime: '2020-03-22T11:52:36.328Z',
  creatorId: {...},
  latestSupportedTlsVersion: 'v1_2'
}
Run Code Online (Sandbox Code Playgroud)

但是,当我实际进入 Azure AD 并删除用户时,我从未收到对我的端点的任何请求...您知道我在这里做错了什么吗?

我已经看到在我们的 MS Graph Webhook 上未收到删除 AAD 中用户的请求,但我都等待了 30 分钟,并尝试了软删除 + 硬删除。两者似乎都没有触发对我的端点的任何类型的请求。

And*_*sen 2

好吧,看来我只是不够耐心。MS可能需要几个小时才能发送这些通知请求。

如果你正在开发 Webhook 终结点并希望对其进行测试/调试,请在 Azure AD 中执行该操作,然后在几个小时内执行其他操作,直到最终收到请求。