I am trying to create a simple custom administrative UI for adding, updating, and deactivating users using the Management API. Additionally, the users administrated will need to have two custom attributes: company which comes from my application’s database, and user_type, which is initially “user” or “administrator”.
PROBLEM 1: Listing All Users
I was able to list all users using the Management API by calling getUsers and paging through results. But, according to the limitations in the documentation (Retrieve Users with the Get Users Endpoint), there is no endpoint for retrieving an immediately consistent list of all users in real-time. I could call get user by email or get user by id if I had the email addresses or ids of my users. But, I don’t know how to get these.
PROBLEM 2: Creating New Users
The createUser code below returned: statusCode: 400, error: ‘Bad Request’, message: “Payload validation error: ‘Missing required property: connection’.”, errorCode: ‘invalid_body’. See the sample code below.
//-----------------
app.get(“/createUser”, async (req, res) => {
var newUser = {
“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”: “//secure.gravatar.com/avatar/15626c5e0c749cb912f9d1ad48dba440?s=480&r=pg&d=https%3A%2F%2Fssl.gstatic.com%2Fs2%2Fprofiles%2Fimages%2Fsilhouette80.png”,
“user_id”: “abc”,
“connection”:“Username-Password-Authentication”,
“password”: “secret”,
“verify_email”: false,
“username”: “johndoe”
};
var options = {
method: 'POST',
url: `https://${domain}/api/v2/users`,
params: {
body: newUser
},
headers: {authorization: `Bearer ${mgmtApiAccessToken}`}
};
return axios.request(options).then(function (response) {
res.send(response.data);
}).catch(function (error) {
console.error(error);
});
}); ///createUser
//----------------
So, if it is too difficult to build a custom administrative UI, is there a way I can just lock down the Auth0 dashboard so that some dashboard users can only add, update, and delete users but also provide company and user_type? I see that, if I upgrade, I can create tenant members who only have the ability to view and edit users. Though, this does not fulfill my need to have them easily add companies and user_types…