如何在用户启用两步验证时收到更新通知?

时间:2021-10-24 06:49: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.

这在我在Admin SDK GUI中更新用户时成功发送通知。但是,当用户采取导致其信息更新的操作(例如登录,更改其密码或启用两步验证)时,我不会收到任何通知。

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?

我的最终目标是在用户启用两步验证时收到通知,即当isEnrolledIn2Sv属性从False更改为True时。有没有办法做到这一点?

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.

编辑:我使用的解决方法是创建一个webhook(我使用AWS Lambda)来查询已知将isEnrolledIn2Sv属性设置为False的所有用户,并查看是否有任何更改为True。有用!但不理想,所以如果有其他人知道更清洁的方法,那就更愿意听到。

1 个解决方案

#1


1  

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

除了“更新”之外,您还希望申请“添加”事件。

#1


1  

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

除了“更新”之外,您还希望申请“添加”事件。