microsoftgraph / msgraph-sdk-javascript

Microsoft Graph client library for JavaScript
https://graph.microsoft.com
MIT License
730 stars 220 forks source link

Subscriptions: Once notification url is validated it no longer gets validated #1641

Closed BillyCottrell closed 3 months ago

BillyCottrell commented 4 months ago

Bug Report

Prerequisites

For more information, see the CONTRIBUTING guide.

Description

So I have been trying to setup subscriptions for a few months now and everything seems to work. The only problem I have is that when I create a subscription for a room the notification url gets validated. If I then delete the subscription and create it again it doesn't get validated, even if I then add the lifecycleUrl. Which causes the lifecycleUrl to not be used and the subscription expiring without any notice.

This is the code that I am using for this (fyi this is typescript in combination with the definitely typed, Microsoft Graph type declaration):

const expirationDateTime = new Date();
expirationDateTime.setDate(expirationDateTime.getDate() + 2);
const client = GraphAuthManager.getAuthenticatedClient(accessToken);
let subscription: Subscription = await client.api(`/subscriptions`).post({
    changetype: "created, updated, deleted",
    notificationUrl: `https://**domainName**/calendars/msgraph/notify-resource`,
    lifecycleNotificationUrl: `https://**domainName**/calendars/msgraph/notify-subscription-lifecycle`,
    resource: `users/${roomIdCalendar}/events`,
    expirationDateTime: expirationDateTime.toISOString(),
});

Steps to Reproduce

(if you have the auth setup done)

  1. Create subscription with notification url for a mailbox
  2. Subscription should try to validate url by sending tokens
  3. When validated subscription should be created
  4. Delete that same subscription
  5. Create subscription with the same mailbox and notification url and also add a lifecycle url
  6. Subscription no longer tries to validate either notification or lifecycle url
  7. Lifecycle url never gets called

Expected behavior: subscriptions tries to revalidate because a lifecycle url was added and wasn't validated yet

Actual behavior: subscriptions lifecycle url never used

Additional Context

Add any other context about the problem here..

Usage Information

Request ID - Value of the requestId field if you are receiving a Graph API error response

SDK Version - 3.0.7

Node Version - 20.11.5

Any ideas what is going on?

Thanks in advance!

BillyCottrell commented 3 months ago

No idea but after trying this out every day and not wanting to work it now suddenly works again. No idea what happened...