Keywords: account linking, client-side implementation, user initiated
Auth0 supports the linking of user accounts from various identity providers. This allows users to authenticate from any of their accounts and still be recognized by your app and associated with the same user profile. Account linking can be initiated by users. Below is the Client-Side Implementation.
- Create a SPA and add the http://localhost:3000 to “Allowed callback URL”, “Allowed logout URL”, and “Allowed Web Origins” fields.
- Go to GitHub - auth0-samples/auth0-link-accounts-sample: Examples of how to implement account linking to download the sample application.
- Open the Terminal window and download the application locally and open the project.
$git clone https://github.com/auth0-samples/auth0-link-accounts-sample.git $cd auth0-link-accounts-sample/ $cd SPA $code .
- Update the domain and client_id in the auth_config.json file.
- Open Terminal window in VS Code and run:
$npm install $npm start
- Go to http://localhost:3000 to open the Account Linking Sample Application and click on the “Log in” button.
- Login with a Google Account
- Click on “Link Account” and enter a username and password pair.
- In the Account Linking pop-up window, click on “Continue”.
- The two users are linked successfully.
- Verify the user in the Auth0 Dashboard
- We can only link the verified user accounts
- The two linked accounts do not require to have the same email addresses.