Auth0 Home Blog Docs

How to assign roles to multiple users?

auth0
authorization-extens

#1

I have a csv file in which there are around 1000 users and I want to assign them roles through Authorization extention. So is there anyway to do it automatically via some sdk? Like for management api and authentication api we have a sdk https://github.com/auth0/auth0.net but for Authorization extension I couldn’t find any sdk. I could only find this link https://auth0.com/docs/api/authorization-extension#introduction
So is there anywau to achieve this functionality other than manually add roles for each user.
Thanks


#2

Hello @jah,

I’m fairly certain the only way to do this would be REST calls to the authz API endpoints, per the documentation you linked, specifically:


#3

Hi @markd,
Yes, I have done the same. Called authz api endpoint “Add User to Roles” (/users/{user_id/roles). The only issue was role_id. I couldn’t find role_id so I assigned role to one user manually and inspect the http call for role_id and then created a small utility that did the rest.