- Link separate user accounts from different providers, tying them to a single profile. To learn more, read User Account Linking.
- Unlink user accounts, returning them to separate identities.
- Update user metadata. To learn more, read Understand How Metadata Works in User Profiles.
Initialize the UsersAPIClient
To get started, create a newUsersAPIClient
instance by passing it the account
and the token for the primary identity. In the case of linking users, this primary identity is the user profile that you want to “keep” the data for, and to which you plan to link other identities.
Link users
Linking user accounts lets a user authenticate from any of their accounts. No matter which account they authenticate with, they log in with the same profile. Without account linking, Auth0 treats every different account as a separate profile. Thelink
method accepts two parameters: the primary user id and the secondary user token (the token obtained after login with this identity). The user id in question is the unique identifier for this user account. If the id is in the format facebook|1234567890
, the id required is the portion after the delimiting pipe.
Unlink users
Unlinking users returns the accounts to separate profiles. Theunlink
method takes three parameters: the primary user id, the secondary user id, and the secondary provider (of the secondary user).
Updating user metadata
When updating user metadata, you create ametadata
object and then call the updateMetadata
method, passing it the user id and the metadata
object. The values in this object overwrite existing values with the same key, or add new values for those that don’t yet exist in the user metadata.