Dale Chen
Dale Chen

Reputation: 11

Webhook on Users in Microsoft Graph API

Is there a way to receive webhooks on Users through the Microsoft Graph API? I'm interested in receiving a call if a user has been added to the client's tenant in their Office365 AAD. If not, is there a way to know if the users have changed, or is the best solution to poll the users api endpoint on a regular interval?

Upvotes: 1

Views: 1520

Answers (2)

Saca
Saca

Reputation: 10672

As noted by Fei Xue, while the Microsoft Graph does support webhooks, it currently doesn't do so for Users and Groups yet (in the works).

As you suggested, you'll need to poll the Graph. You can however, leverage the Differential Query (DQ) feature to avoid having to figure out the deltas yourself. When you poll the Graph using DQ, you'll get a list of all the users, all the attributes you select to be informed about (via $select) and a continuation token. The next time you poll, you'll pass along that continuation token and the Graph will know to send you back only the things that have changed since - Users added/remove or attributes changed. This is also available for Groups.

NOTE: Differential Query is only available in the Azure AD Graph which is the underlying API that powers the the Azure AD related features of the Microsoft Graph (Users, Groups, Application, Service Principals, etc)

More info on Differential Query: https://msdn.microsoft.com/en-us/Library/Azure/Ad/Graph/howto/azure-ad-graph-api-differential-query

Upvotes: 1

Fei Xue
Fei Xue

Reputation: 14649

At present, Microsoft Graph supports subscribe to changes on the following resources: Messages, Events, Contacts, Group conversations. It doesn't support to subscribe the changing for the users.

If not, is there a way to know if the users have changed or is the best solution to poll the users api endpoint on a regular interval?

A possible way is that when we add the users using the Office 365 portal, we are required to provide an email address to receive the password like figure below: enter image description here

You can use the specific email address in your tenant and add an subscribe to the messages. More detail about Microsoft webhooks, please refer to here.

Upvotes: 2

Related Questions