Is account linking possible in free plan
Hi @yondela08
You are asking whether account linking (merging multiple user identities into a single user profile) is available on Auth0's free plan.
Yes, account linking is available on the free plan. You can link multiple identities to a single user account using the Management API or Post-Login Actions, regardless of your pricing tier.
[Root Cause]
Account linking is not a premium feature in Auth0. It is a core identity management capability available on all plans, including Free, Professional, and Enterprise.
How Account Linking Works:
Account linking allows you to merge multiple identities (e.g., a user's Google login, GitHub login, and email/password login) into a single user profile. After linking, the user can log in with any of their linked identities and access the same account.
Example Scenario:
- User logs in with Google on Day 1 → Creates a user profile
- User logs in with GitHub on Day 2 → Without linking, this creates a second user profile
- With account linking → Both identities are merged into one profile, and the user can log in with either Google or GitHub
Solution: Link Accounts via Management API
Step 1: Authenticate to the Management API
First, obtain an access token for the Management API:
const ManagementClient = require('auth0').ManagementClient;
const management = new ManagementClient({
domain: 'YOUR_DOMAIN.auth0.com',
clientId: 'YOUR_CLIENT_ID',
clientSecret: 'YOUR_CLIENT_SECRET'
});
Step 2: Link a Secondary Identity to a Primary User
Use the Management API to link identities:
// Primary user ID (the account you want to keep)
const primaryUserId = 'auth0|user123';
// Secondary identity to link (the account you want to merge)
const secondaryIdentity = {
connection: 'google-oauth2',
user_id: 'google-oauth2|1234567890'
};
// Link the accounts
await management.users.link(primaryUserId, secondaryIdentity);
Step 3: Verify the Link
After linking, retrieve the user to confirm both identities are present:
const user = await management.users.get({ id: primaryUserId });
// user.identities will now contain both:
// - { connection: 'auth0', user_id: 'user123', ... }
// - { connection: 'google-oauth2', user_id: '1234567890', ... }
Automatic Account Linking with Post-Login Actions
You can automate account linking during login using a Post-Login Action:
exports.onExecutePostLogin = async (event, api) => {
// Check if user has multiple identities
if (event.user.identities && event.user.identities.length > 1) {
console.log(`User ${event.user.user_id} has multiple linked identities`);
// Identities are already linked; no action needed
}
};
Account linking is a core feature available on all Auth0 plans and can be implemented immediately on the free tier.
Kind Regards,
Nik