Post registration hook - post request

Hi,

I’d like to post a request to my express api to pass in the user metadata to an api endpoint and have that essentially posted to the database. I am wondering how this works from auth0:
A user registers to my app in frontend, the post register hook gets called… but how can i pass this info along? … In addition, I am planning on configuring my rest express api to also authenticate as well.

Please advise.

Thank you!

@SaqibHussain @konrad.sopala
Would appreciate any help for this.
Thank you!

Hey @jerryforcode

Thanks for getting in touch with us at Community :slight_smile:

To get the user_metadata you’ll need to create a rule to add the metadata to the id_token as a custom claim, then it will become available in the user profile, please see https://auth0.com/docs/configure/apis/scopes/sample-use-cases-scopes-and-claims#add-custom-claims-to-a-token

To authenticate in your express rest api please review https://auth0.com/docs/quickstart/backend/nodejs in the first instance.

Let me know if you need any further info on this.

Regards

1 Like

Hi @SaqibHussain,

This information is helpful however how does this look like in the hook?

I want to do a post request so I’m assuming

Something like

var request = require(‘request’);

request({
method: ‘POST’,
url: ‘my_rest_endpoint_url is here’,
headers: {
‘Content-Type’: ‘application/json’,
},
body: { "firstname": "${user.username}", "username": "${user.id}”}
}, function(error, response, body) {
console.log(user)
console.log(context)
cb(error, response)
});

How do I pass the token so that my express api can I identify it?

Please advise

Thanks!

Hey @jerryforcode
I think you have this information now, please let me know if you still need help with it.
Regards

1 Like