Lazy Migration Between Two Auth0 Tenants

Problem statement

As an alternative to exporting and importing password hashes, is it possible to achieve automatic migration between two Auth0 tenants/databases using a custom action script for automatic/lazy migration?

Solution

While there is no official documentation explaining how to achieve this use case, there is a GitHub repository with a step-by-step guide from an Auth0 Solutions Architect.

For reference, this is a sample Login and Get User script. For clarification, in step 5, “Required Grant Types”, the second paragraph is incorrect and should actually read:

For those interested to dig deeper, "Password" grant type is used to validate user's input username and password in login.js and "Client Credentials" is used to generate a new management API `access_token` so get_user.js can invoke search API.

NOTE: This code is for reference purposes only and is not assumed to be production-ready. Please test and customize accordingly.