Problem statement
We would like to migrate users from one database connection to another database connection. The user data that need to be migrated are:
- User profile data, including email, email_verified, app_metadata, user_metadata and etc
- User password hash
- User’s assigned permissions
Solution
Unfortunately, the above information cant be exported/imported via a single API endpoint, but we can provide the steps on how to export/import them in detail.
- Export
User profile data, including email, email_verified, app_metadata, user_metadata, etc.
You can use the bulk user export feature to export this information:
https://auth0.com/docs/manage-users/user-migration/bulk-user-exports
You can specify which fields of the user profile to export, but please note that you can only export as JSON format if you would like to export a user profile field that is an object (e.g. user_metadata) or an array (e.g. identities).
- User password hash
The user password hash can only be exported by Auth0 via a support ticket. In order to handle that create a support ticket via support.auth0.com.
- User’s assigned permissions
You can export the user’s assigned roles via the following Management API endpoint:
https://auth0.com/docs/api/management/beta/v2/get-a-users-permissions
-
Import
-
User profile data, including email, email_verified, app_metadata, user_metadata, etc.
-
User password hash
You can combine the user profile data and the user password hash into one JSON file and import them together:
https://auth0.com/docs/manage-users/user-migration/bulk-user-imports
https://auth0.com/docs/manage-users/user-migration/bulk-user-import-database-schema-and-examples
- User’s assigned permissions
You can use the following Management API endpoint to import the user’s assigned permissions:
https://auth0.com/docs/api/management/beta/v2/assign-permissions-to-a-user