-
Log the user into your application.
The user authenticates to your application using Universal Login. To learn more, read the Regular Web App Quickstart, asking for a token for the Auth0 Management API audience (audience=https://{yourDomain}/api/v2/
). -
Search for users with identical email addresses.
You can get the user profile and the list of users with the same verified email.To get a list of all of the user records with the same email address, your application calls the Auth0 Management API’s Get Users By Email endpoint using a Management API Access Token with theread:users
scope. -
Prompt the user to link accounts.
- If Auth0 returns one or more records with matching email addresses, the user will see the list along with the following message prompting them to link the accounts.
-
If the user wants to link a given account, they can click Link next to the appropriate account.
-
When the user clicks Link, your application will ask the user to authenticate with the target account, and then perform account linking.
The following code snippet shows how to verify and merge metadata:To retain and merge the
user_metadata
from the secondary account, you must retrieve and merge it into the metadata for the primary account before calling the API endpoint. After the accounts are linked, the metadata for the secondary account is discarded.When you initiate account linking, you can select which identity will be used as the primary account and which as the secondary. This choice will depend on which set of attributes you want to retain in the primary profile. -
Your application calls the Auth0 Management API’s Link a User Account endpoint using a Management API Access Token with the
update:users
scope.
Metadata merge example
The following example shows explicitly how theuser_metadata
and app_metadata
from the secondary account gets merged into the primary account using the Node.js Auth0 SDK for API V2.