Auth0 Home Blog Docs

Unable to create user calling management API on custom database

custom-database
migration
create-user

#1

Hello, I am using a custom database to gradually import users from Okta to Auth0.
I have disabled signups.
Login works fine : Okta users are correctly imported in my CustomDB but when I try to create new users calling the management api, an error seems to occur in the Create Usescript.
I’m getting the following error message:
{
“code”: 400,
“message”: “Compilation failed: Unexpected token export”,
“error”: “Unexpected token export”,
“stack”: “/data/io/1426e76d-d9fe-40db-9c1d-002929bbf5f9/webtask.js:6\n (export default function getByEmail(email, callback) {\n ^^^^^^\n\nSyntaxError: Unexpected token export\n at createScript (vm.js:80:10)\n at Object.runInThisContext (vm.js:139:10)\n at WebtaskModule.compileWebtask (/data/sandbox/lib/module.js:92:32)\n at defaultJavascriptCompiler (/data/sandbox/lib/compiler.js:119:30)\n at defaultCompiler (/data/sandbox/lib/compiler.js:128:16)\n at /data/sandbox/lib/compiler.js:231:17\n at /data/sandbox/node_modules/async/dist/async.js:3880:24\n at replenish (/data/sandbox/node_modules/async/dist/async.js:1011:17)\n at /data/sandbox/node_modules/async/dist/async.js:1016:9\n at eachOfLimit (/data/sandbox/node_modules/async/dist/async.js:1041:24)”
}
I don’t have any custom Create User script so I can’t debug to understand what’s happening.
The only custom scripts configured for my database are Login script and Get User Script.

Posting the following JSON on a non custom database works fine but not on my custom database
{
“password”: “Secret888”,
“email_verified”: true,
“user_metadata”: {
“app_name”: “Optim”,
“last_name”: “Doe”,
“first_name”: “John”
},
“name”: “John Doe”,
“connection”: “hello-world”,
“email”: "johnd@schoelcher.com",
“username”: “johnd”,
“app_metadata”: {
“optim”: {
“tenant_ids”: [
“4746335225373925147”
]
}
}
}

Thank you in advance for your help


#2

I solved my issue thanks to this post :


Adding a user with the management API triggers the Get User script .
Mine was obviously not working with the version of Node.js installed on my tenant.