Api/v2/users?page help

Ready to post? :magnifying_glass_tilted_left: First, try searching for your answer.
Hi

I am unable to get the paging to work to get all by users, i bulk imported users using import/export extension , now i want to get those users and assign roles to them using v2/roles api , but the paging parameter does not work , only first 2 pages return users after that it keeps giving my empty json , I have some 120 users thats all , also is there a way to assign roles in bulk itself

Thanks

Hi @imntest111

Welcome to the Auth0 Community!

The page parameter will return 50 users, it does not resemble the exact page within the Auth0 Dashboard. Since the parameter starts at 0, by page 3 it will return empty JSON since there are no users on that page. This being said, if you query the page using:

  • https://{{Auth0_domain}}/api/v2/users?page=0
  • https://{{Auth0_domain}}/api/v2/users?page=1
  • https://{{Auth0_domain}}/api/v2/users?page=2

These queries should return all of your users since you mentioned that you have around 120.

To answer your second question, unfortunately, you cannot assign roles in a bulk, by using the Management API endpoint, you can assign them only one at a time.

If you have any other questions, feel free to leave a reply!

Kind Regards,
Nik

Ok thanks , also i was using the import / export extension to import users , but i also see management/v2/jobs/post-users-imports where u can upload a json , but for me the test endpoint button is disabled and i cannot change the domain also in the curl , how do i use that interface , thanks

I see.

Please double check if you have set the Management API key or if it is the correct one. Otherwise, you can attempt to log out and back in since it might be a display bug.

Otherwise, you can attempt to use the cURL request from this documentation:

curl --request POST \
  --url 'https://{{AUTH0_Domain}}/api/v2/jobs/users-imports' \
  --header 'authorization: Bearer MGMT_API_ACCESS_TOKEN' \
  --form users=@USERS_IMPORT_FILE.json \
  --form connection_id=CONNECTION_ID \
  --form external_id=EXTERNAL_ID

Let me know if that helps!

Kind Regards,
Nik

thanks that worked , is there a recommend way to migrate aws cognito users to auth0 , i want to map the aws groups also to the auth0 roles , i see that Automatic migrations or lazy migration is also an option

thanks

Hi again @imntest111

In order to be able to do Automatic Migration on your Auth0 Tenant, you will need to be under a Professional subscription which allows you to create a Database with a connection to your own custom one. For the recommended approach, any option is suitable, it just depends to your own use case and necessities regarding the matter.

Otherwise, regarding importing their roles, if the userโ€™s roles are mapped inside their profile, you will need to write additional code when using a custom database or create a Post Login Action which will assign the roles inside the user mapping to actual roles created within the Dashboard. You can review our documentation regarding assigning a role to a user using the Management API.

Let me know if you need anything else!

Kind Regards,
Nik

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