Adding user metadata in the pre-user registration hook

Hi, I’d like to access user_metadata in the pre-user registration hook. My use case is to use some of the metadata passed to webAuth.redirect.signupAndLogin to make an external request in the hook and then add to the user_metadata with the response I get from that external request.

However it appears that the metadata I am passing to webAuth.redirect.signupAndLogin is not available there. That metadata is available in the user-post registration hook (but my understanding is that I cannot add to user_metadata in the post registration hook), furthermore the metadata does get set on the user when I view it in the auth0 web interface, but that metadata isn’t returned in when requesting the user’s profile.

Am I missing something or is it not possible to access metadata passed to webAuth.redirect.signupAndLogin in the pre registration hook?

Also is it not possible to add to user metadata in the post registration hook?

I don’t think I can do this work in a rule because I need to make the external request with secret credentials and I don’t see any way to set a secret in a rule.

Hi @jaredgalanis1,

Welcome to the Community!

I think you should be able to do what you are describing. Can you share your code so I can trouble shoot the issues? Here is a thread that describes how to send a param to the pre reg hook:

and here is a thread that describes how to add it to the user_metadata property:

This issue is because it isn’t automatically returned in the user profile. Here is a thread that shows how to set up a rule that returns user_metadata in the id token:

It is actually possible to do this in rules, and if you are wanting to add this property to social users you would have to do this in a rule. Hooks don’t run for non-database users.

You can add credentials in rules in the configuration object:

I know that is a lot of info so please let me know if you have questions!

1 Like

Thanks for that @dan.woda! I ended up accessing the management API directly, but I’ll keep these tips in mind if I end up needing something like this in the future.

1 Like

Sounds good. Thanks for the update!

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.