I’m looking into a way to keep our backend in sync with email (and phoneNr) changes. As far as I know there is no such post-profile-update-action, or at least I can’t find it in the docs…
Hi pepijn.
In your backend, implement the scheduler to pull user data from Auth0 and sync it with your database
- Pull user data by this API: Auth0 Management API v2 using the query with field of
update_at
to collect the latest updated data - Sync the
phone
&email
&update_at
to your database backend byuser_id
(*)Note: How do we get the latest update_at
for query of step#1, it is max of update_at
we collect in step#2.
The downside of this approach depends on the schedule time you are setting up.
Hope it can help.
I have not tried this, but one idea that might work is to set up a Custom Webhook on your end and create an Auth0 Log Stream to send the sce
event logs to it (or scpn
for phone number)
Select only the User/Behavioral - Success
event category to send to this custom webhook and look for the incoming sce
Successful Change Email and scpn
Successul Change Phone Number log events
Hope this solution helps.
Thanks, that log stream looks interesting. However the web hook retry mechanism is a bit of a risk:
“If your server is unable to receive the event, we will retry up to three times to deliver the event”
Why three times? With what backoff period? Will it just fail and continue with the next one?
This can be a risk, for example, when the backend goes down during a very busy day. Do I need to fix all the missing data because of the failed web hooks manually? Normally you would expect the stream just blocks and the system retries the last failed event with some form of (exponential) backoff.
Thanks MJ, I tend to prefer your proposed solution as it seems to be the most error-proof and robust. However there is a risk that there is a collision in update_at
and that the puller gets stuck. I’m going to check out the combo of the pulling and the event-logs and see if I can robustly pull the event-logs.
@pepijn.knetsch I understand your concerns, I’m not familiar enough to know why Auth0 would attempt to retry only three times. Perhaps an Auth0 employee can shed some more info on that for you.
However, users who simply log into your applications will have the updated_at
field updated in Auth0 automatically, due to last_login
, logins_counts
, etc profile fields being updated for the user.
So if you query users based on updated_at
with the /api/v2/users endpoint, you will be pulling in many users who do not make Email or Phone Number changes.
If you prefer to have a more proactive approach and want to check for Change Email/Change Phone Number updates periodically yourself instead of using the Log Stream, you can also query the Auth0 tenant logs via the Management API /api/v2/logs endpoint and use the query params to search for sce
and scpn
events between date ranges.
Hey there!
As this topic is related to Actions and Rules & Hooks are being deprecated soon in favor of Actions, I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!