CONTEXT:
- Using Auth0 Management SDK.
- Using a custom M2M application
User API
(in the photo there’s the list of my applications)
- The API
Auth0 Management API
(created by default by Auth0) authorizes some permissions/scopes (create:users delete:users read:users read:user_idp_tokens read:roles update:users
) for the M2M applicationUser API
CODE:
const {
ManagementClient
} = require('auth0');
const auth0Management = new ManagementClient({
domain: process.env.AUTH0_DOMAIN,
clientId: process.env.AUTH0_CLIENT_ID_USERAPI,
clientSecret: process.env.AUTH0_CLIENT_SECRET_USERAPI,
scope: 'create:users delete:users read:users read:user_idp_tokens read:roles update:users'
});
...
const user = {
email: 'john.doe@gmail.com',
phone_number: '+199999999999999',
user_metadata: {},
blocked: false,
email_verified: false,
phone_verified: false,
app_metadata: {},
given_name: 'John',
family_name: 'Doe',
name: 'John Doe',
nickname: 'Johnny',
picture: 'https://secure.gravatar.com/avatar/15626c5e0c749cb912f9d1ad48dba440?s=480&r=pg&d=https%3A%2F%2Fssl.gstatic.com%2Fs2%2Fprofiles%2Fimages%2Fsilhouette80.png',
user_id: 'test|1234567890',
connection: 'Initial-Connection',
password: 'Asdfs-f951',
verify_email: false,
username: 'johndoe'
};
await auth0Management.createUser(user);
...
PROBLEM:
When I try to create a user with Auth0 SDK, I receive this message:
name: 'Bad Request',
message: 'The connection does not exist.',
statusCode: 400,
requestInfo: {
method: 'post',
url: 'https://<my tenant name>.auth0.com/api/v2/users'
},
originalError: {
Error: Bad Request
at Request.Object. < anonymous > .Request.callback(D: \Codi\ Code\ au\ node_modules\ superagent\ lib\ node\ index.js: 706: 15)
at parser(D: \Codi\ Code\ au\ node_modules\ superagent\ lib\ node\ index.js: 916: 18)
at Stream.res.on(D: \Codi\ Code\ au\ node_modules\ superagent\ lib\ node\ parsers\ json.js: 19: 7)
at emitNone(events.js: 106: 13)
at Stream.emit(events.js: 208: 7)
at Unzip.unzip.on(D: \Codi\ Code\ au\ node_modules\ superagent\ lib\ node\ unzip.js: 55: 12)
at emitNone(events.js: 111: 20)
at Unzip.emit(events.js: 208: 7)
at endReadableNT(_stream_readable.js: 1064: 12)
at _combinedTickCallback(internal / process / next_tick.js: 138: 11)
at process._tickCallback(internal / process / next_tick.js: 180: 9)
status: 400,
response:
Response {
domain: null,
_events: {},
_eventsCount: 0,
_maxListeners: undefined,
res: [Object],
request: [Object],
req: [Object],
text: '{"statusCode":400,"error":"Bad Request","message":"The connection does not exist.","errorCode":"inexistent_connection"}',
body: [Object],
files: undefined,
buffered: true,
headers: [Object],
header: [Object],
statusCode: 400,
status: 400,
statusType: 4,
info: false,
ok: false,
redirect: false,
clientError: true,
serverError: false,
error: [Object],
created: false,
accepted: false,
noContent: false,
badRequest: true,
unauthorized: false,
notAcceptable: false,
forbidden: false,
notFound: false,
unprocessableEntity: false,
type: 'application/json',
charset: 'utf-8',
links: {},
setEncoding: [Function: bound],
redirects: []
}
}
QUESTION:
What is the cause of the problem?