Notification for lifecycleEvent "subscriptionRemoved" not getting triggered by password change on Microsoft Graph API

Viewed 355

I'm using the Microsoft Graph API to subscribe to notifications for calendar events through Node. Upon reading the documentation for best practices for Reduce missing subscriptions and notifications for Outlook resources (preview), it says that:

Certain events in Outlook can cause a subscription to be removed. These events include:

  • User's password has been reset
  • User's device is out of compliance
  • User's account has been revoked

When such an event happens, Outlook sends a special lifecycle notification, subscriptionRemoved.

Outlook also sends another lifecycle notification, missed, if a notification cannot be delivered to an app.

An app subscribing to notifications for Outlook resources, such as message and event, should listen to the subscriptionRemoved and missed signals:

  • Upon receiving a subscriptionRemoved notification, the app should recreate the subscription in order to maintain a continuous flow.
  • On receiving a missed notification, the app should resynchronize resource data using Microsoft Graph.

To receive lifecycle notifications, you can use the existing notificationUrl endpoint that already receives resource notifications, or you can register a separate lifecycleNotificationUrl to receive subscriptionRemoved and missed notifications in a separate endpoint.

After I subscribed to a user's calendar events, I get the changes notifications without any issues, but if I change the user's password I should get the lifecycleEvent notification subscriptionRemoved like it says above; however, after changing my password about 30 times I never got the notification. What could be the issue here? I couldn't find any more info about how to trigger the notification.

If it helps with anything I'm subscribing to the resource me/events with a changeType: "created,updated,deleted".

  const subscriptionOptions = {
    changeType: 'created,updated,deleted',
    notificationUrl: `node-service-url/outlook-events/${userId}`,
    resource: 'me/events',
    expirationDateTime: 'someExpirationDateTime',
    clientState: 'someClientState'
  }

  const subscription = await client
    .api('/subscriptions')
    .post(subscriptionOptions)
1 Answers

If you want to listen to lifecycle events, then while creating a subscription, you must specify a notification endpoint using the lifecycleNotificationUrl property. If you specify the endpoint, all current and future types of lifecycle notifications will be delivered there. Otherwise, subscriptionRemoved and missed lifecycle notifications will not be delivered. This endpoint can be the same as the notificationUrl or a different one.

In your case, you have not set this property.

Please see official documentation - https://docs.microsoft.com/en-us/graph/webhooks-lifecycle#creating-a-subscription

Related