Hi,
I am new to Auth0, I have created a testing account in auth0
created two Single pages application ie ‘ProjectDevelopment’ and ‘ProjectProduction’ and two API’s ie https://project-dev.io and https://project-production.io
and enabled ‘RBAC’.
Everything works for me in the development application my application flows as follows
- Disable signup because it is an invite-only application(Done by referring this Send Email Invitations for Application Signup)
- Create roles by calling auth0 api
- Add permission to Role
- Create user and assign role to user
In production am trying to do the same but when i try to create a ‘role’ create role api throwing error ie
“error”: “{"statusCode":409,"error":"Conflict","message":"The role already exists."}”,
I cannot create a same ‘role’ in two different applicaitons, I also tried with using different database for two apps but its again saying my role already
exists in my development applicaiton.
I would like to know two things
- How to create the same role in two different application?
- Is there any restriction to create the same user in different applications?
code I am using for creating the role
Generate token
auth0Domain = dev-test.auth0.com
const auth0 = new AuthenticationClient({
domain: config.api.auth0Domain,
clientId: config.api.auth0ClientId,
clientSecret: config.api.auth0ClientSecret,
});
auth0.clientCredentialsGrant(
{
audience: `https://${config.api.auth0Domain}/api/v2/`,
},
(err, response) => {
if (err) {
// Handle error.
debug(`auth0 created error ${err}`);
reject(err);
} else {
// debug(`auth0 token generated`, response.access_token);
resolve(response.access_token);
}
})
Create Role
const management = new ManagementClient({
token: accessToken,
domain: config.api.auth0Domain,
});
management
.createRole(data)
.then((roleRes) => {
debug(auth0 createRole success ${JSON.stringify(roleRes)}
);
resolve(roleRes);
})
.catch((err) => {
// Handle error.
debug(auth0 createRole error ${err}
);
reject(err);
});