POST request post registration hook

I am trying to run a POST request to my server url and I have auth0 layer to determine if the user is authenticated. The auth layer only accepts a JWT token and so im trying to add it to the Authorization Bearer Token but it seems like in the tests it gets ignored… Am i doing this correctly?

module.exports = function (user, context, cb) {
 const request = require('request');

    method: 'POST',
    url: ‘path/to/url’,
    headers: {
      'Content-Type': 'application/json',
      'Authorization': `Bearer ${context.webtask.token}`
    body: `some body`
  }, function(error, response, body) {
    cb(error, response.body);

1 Like

Hi @jerryforcode,

Thanks for reaching out to the Auth0 Community!

First, I want to clarify that in the Post Registration Hook, it would not be worth checking if the user is authenticated since:

  1. If it’s an authenticated user then they cannot be created since they exist, and
  2. The hook triggers after creating a new user, but before they log in, hence the result will always determine the user as unauthenticated.

Because of that, could you please clarify what you intend to do?

And, could you please clarify your server URL? Is that pointing to any of the Auth0 APIs, or is it another URI?

Looking forward to your reply.

Thank you.

Hi @rueben.tiow,

Thanks for getting back to me.

This will be going to another URI however, I am using this hook to create the user info in my database so I can store it for my records.
I added the auth0 layer for security reasons as it will be inserting records into my database. Unless there is another way to validate that the insertion is coming from auth0 ?