24

I have created a channel to send my app notifications when a user is updated like so:

data = {
    'id': channel_id,
    'type': 'web_hook',
    'address': domain_address,
    'kind': 'api#channel',
}
channel = directory.users().watch(body=data, domain=my_domain, event='update').execute()

This successfully sends notifications when I update the user in the Admin SDK GUI. However, when a user takes an action that causes their information to update, such as logging in, changing their password or enabling 2-step verification, I receive no notification.

My end goal is to receive a notification when a user enables 2-step verification, i.e. when the isEnrolledIn2Sv attribute changes from False to True. Is there any way of doing this?

Thank you!

EDIT: The workaround I used was to create a webhook (I used AWS Lambda) to query all users known to have the isEnrolledIn2Sv attribute set to False, and see if any had changed to True. It works! But not ideal, so would love to hear if anyone else knows a cleaner way to do this.

MaryKN
  • 250
  • 1
  • 6
  • You may want to use the [`Users: watch`](https://developers.google.com/admin-sdk/directory/v1/reference/users/watch) which watches for changes in users list. You may also check the [Directory API](https://developers.google.com/admin-sdk/directory/v1/guides/push) which provides push notifications that let you watch for changes to resources. Currently, the Directory API supports notifications for changes to the [Users](https://developers.google.com/admin-sdk/directory/v1/reference/users/watch) resource. – abielita Jun 20 '17 at 15:43
  • I believe that's what I have set up here - it calls the watch command on the users resource on the directory API. Did I not do it correctly? – MaryKN Jun 20 '17 at 16:02

1 Answers1

1

In addition to 'update', it looks like you want to request 'add' events, as well.

J_H
  • 17,926
  • 4
  • 24
  • 44