Hi there! So I’m trying to implement the following post-user-registration hook:
module.exports = function(user, context, cb) {
var axios = require('axios');
axios
.post(
'https://bb89cc037d18.ngrok.io/interview/post', {email: user.email})
.then(res => console.log(res))
.catch(err => console.log(err));
cb();
};
My backend has Auth0 implemented and also checkJwt
middleware for each endpoint. When I run the script above, the response in the logs is the following:
Error: Request failed with status code 401
And a very long detail after that. I just don’t understand why it’s a 401, given that the Hook testing shell in Auth0 platform automatically assigns a Bearer ACCESS_TOKEN to avoid 401 error. I tried sending headers authorization token straight in the hook axios options argument but of course, that overlaps with the authorization header that auth0 sets by default in the hook headers testing IDE. I also tried replacing that default authorization header with my ACCESS_TOKEN provided by Auth0 through the cURL method but that would give me a 500 error.
I have no clue about why my backend is rejecting the request by sending a 401, when the request is carrying the corresponding Bearer ACCESS_TOKEN.
Any ideas?