Add role(s) to user during angular ui create process

ok, i can login from my angular UI and get my roles included in the JWT in angular world. they do have that namespacing thing which means there is some tweaking needed to make the roles visible to an .NET Core 6 API Authorize attribute, but that’s ok. what i’m struggling with is the ability of a user, say a user to whom i have given an “admin” role (in the autho management UI), to login to my angular application and then use a form i have created to add another user in my angular UI, select relevant role(s) for that user from a populated dropdown, hit the submit button and have the user created with those roles. i can hard-code the roles dropdown, though it would be nice to be able to retrieve them dynamically from autho at runtime. is all this do-able?

i think this may be a 2-step process. create a user, get back the new id in the response, and then add any selected roles using the id. i think there are exposed endpoints for this? is there a way to get a list of all roles + their id’s for an application?

Hello @aylmer welcome to the community!

You’re on the right track here :slight_smile: You will need to use the Management API to perform the actions described. It sounds like creating a user and then assigning the roles to said user should suffice. You can get roles with this endpoint.

Given this requires the use of the Management API, you will want to perform these actions on your backend which should act as a sort of proxy for your front end. The reason being that Management API access tokens are limited by design for front end use. While certainly possible to interact with the Management API directly from your backend/API, Auth0 does offer several Management API SDK libraries which could be useful:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.