Hi @techdynamism,
I just tested out your code in my own tenant, and it seems to make the update on the user, although the user ID is referenced with event.user.user_id
instead of event.user.id
. You can find the post-user registration event object here: Actions Triggers: post-user-registration - Event Object. It might be helpful to log the secrets to make sure they contain the correct credentials and don’t contain quotes, etc.
As a side note, since you are updating app metadata, you may want to consider using a pre-user registration or post login action instead of a post-registration action.
Post-user registration actions are best suited for tasks such as notifying another system about a signup. Due to the async nature of this trigger, you may encounter unexpected behavior or side effects if you use it to make persistent changes on a user (for example, assigning a role or updating app metadata).
For updating app metadata, it’d be much safer to use a pre-user registration or post login action.
Here is how you can update app metadata in a pre-user registration action:
exports.onExecutePreUserRegistration = async (event, api) => {
api.user.setUserMetadata('alternateId', 123);
};
And here is how you would update app metadata in a post-login action:
exports.onExecutePostLogin = async (event, api) => {
if (event.stats.logins_count === 1) {
api.user.setAppMetadata('alternateId', 123);
}
};
https://auth0.com/docs/actions/triggers/post-login/manage-user-metadata