I am trying to programmatically assign a role to a user after they’ve registered using a “Post User Registration” action and the auth0 npm module. However I’m getting the following error when running the action in Test: “APIError: getaddrinfo ENOTFOUND https”
Here is the code:
exports.onExecutePostUserRegistration = async (event) => {
const user = event.user;
const ManagementClient = require("auth0").ManagementClient;
const auth0 = new ManagementClient({
domain: event.secrets.DOMAIN,
clientId: event.secrets.CLIENT_ID,
clientSecret: event.secrets.CLIENT_SECRET,
scope: 'read:roles update:users create:role_members',
});
const params = { id: user.user_id };
const data = { roles: [event.secrets.ROLE_ID] };
await auth0.users.assignRoles(params, data);
}
And here is the full stack trace
APIError: getaddrinfo ENOTFOUND https
at /data/layers/layers-tdaR/tdaR0pdb0MnYXTf0YLgjesmRJnnEWEwwoVWzGvGbizg/node_modules/rest-facade/src/Client.js:402:25
at Request.callback (/data/layers/layers-tdaR/tdaR0pdb0MnYXTf0YLgjesmRJnnEWEwwoVWzGvGbizg/node_modules/superagent/lib/node/index.js:905:3)
at ClientRequest.<anonymous> (/data/layers/layers-tdaR/tdaR0pdb0MnYXTf0YLgjesmRJnnEWEwwoVWzGvGbizg/node_modules/superagent/lib/node/index.js:822:12)
at ClientRequest.emit (node:events:527:28)
at ClientRequest.emit (node:domain:475:12)
at TLSSocket.socketErrorListener (node:_http_client:454:9)
at TLSSocket.emit (node:events:527:28)
at TLSSocket.emit (node:domain:475:12)
at emitErrorNT (node:internal/streams/destroy:157:8)
at emitErrorCloseNT (node:internal/streams/destroy:122:3)
Is there another way I should be doing this?