MaryKN
MaryKN

Reputation: 250

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

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.

Upvotes: 24

Views: 447

Answers (1)

J_H
J_H

Reputation: 20570

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

Upvotes: 1

Related Questions