How to receive an update notification when a user enables 2-step verification?
Asked Answered
F

1

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.

Fuchsin answered 19/6, 2017 at 22:55 Comment(2)
You may want to use the Users: watch which watches for changes in users list. You may also check the Directory API which provides push notifications that let you watch for changes to resources. Currently, the Directory API supports notifications for changes to the Users resource.Staceestacey
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?Fuchsin
N
1

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

Noelianoell answered 1/1, 2018 at 21:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.