It seems like the code is actually working, since I successfully triggered the webhook while manually running an action, but the problem is that the action doesn’t get triggered at all, because I’m using the social signup.
What would I have to do in order to trigger the webhook after a user has signed up via Google or Facebook signup feature?
Unfortunately, this is is a limitation as the Post User Registration Action is only triggered for database and passwordless connections.
You could look into using a Post Login Action action instead - Something like this comes to mind:
exports.onExecutePostLogin = async (event, api) => {
if (event.stats.logins_count == 1 && event.connection.strategy == "twitter" || "google-oauth2" || "other_social_connection_name") {
//do something considering this is a social connection user and the first time logged in (created).
}
}
Basically, you could rely on an initial login from a social user which in this context equates to a user created. I can imagine several ways this might work, all using a Post Login Action and the event and/or api object(s) found here:
I have not tested this myself, but just an idea - Hope this helps!
+1 to @tyf solution above, but if you need to do a task for initial signups only, you must also include checks in the Auth0 Action against silent authentication/refresh token rotations/etc requests – The Post Login Action is triggered for these events as well and the logins_count will remain as 1 for the user.
You can check the type of event that is occurring by looking at the event.transaction protocol value.
A better method would be to set a flag in the user’s app_metadata object to check against so you know you’ve already done what you needed to do, and skip the task for the user
For example, in addition to what was provided above…
exports.onExecutePostLogin = async (event, api) => {
event.user.app_metadata = event.user.app_metadata || {};
if (event.user.app_metadata.YOUR_FLAG_HERE) return; # skip Action for this user
// Do your initial social signup stuff here
api.user.setAppMetadata('YOUR_FLAG_HERE', true);
}