Prompt

account linking OAuth duplicate users

Technology / Identity & Access3 observationsLast seen Nov 10, 2026

Latest observation

Nov 10, 2026OpenAI APIWeb search: off

Account linking for OAuth is usually the right fix for duplicate users caused by people signing in with the same email through different providers.

Common cause

If your app treats each OAuth provider login as a separate account, then:

  • Google login creates user_123
  • GitHub login with same email creates user_456

This leads to duplicate profiles, split data, and login confusion.

Recommended approach

1. Use a single internal user record

Keep one canonical users table row for the person, and link multiple identities to it.

Example schema:

users

  • id
  • email
  • name
  • created_at

user_identities

  • id
  • user_id → references users.id
  • provider (google, github, etc.)
  • provider_user_id (the provider’s stable unique subject ID)
  • email_at_link_time
  • created_at

Enforce:

  • unique (provider, provider_user_id)
  • optionally unique email if your product rules require it

2. Prefer provider user ID over email

Do not use email alone as the identity key.

Why:

  • emails can change
  • some providers may not verify email
  • same email can appear across providers
  • social providers may return different email states

Use:

  • provider
  • provider_user_id / sub claim from OIDC

3. Link by email only with care

If the OAuth provider gives a verified email, you can offer auto-linking or soft matching, but only if:

  • the email is verified by the provider
  • the existing account is also verified
  • you have a secure linking policy

Safer options:

  • require the user to be logged into the existing account before linking
  • send a confirmation email before merging accounts
  • prompt the user if an email match is found

4. Linking flow options

Safe manual linking

  1. User logs into existing account
  2. In settings, they click “Link Google”
  3. OAuth callback links new identity to current user
  4. Now same user can use either provider

Auto-link with verified email

  1. User signs in with OAuth
  2. You find an existing account with same verified email
  3. Ask the user to confirm linking
  4. If confirmed, attach identity to existing user

Merge duplicate accounts

If duplicates already exist:

  1. Choose a canonical account
  2. Reassign foreign keys/data from duplicate to canonical
  3. Link identities
  4. Disable the duplicate account

5. Important security rules

  • Never auto-merge accounts solely on unverified email
  • Never allow account takeover by linking based only on a guessed email
  • Require the user to prove control of the target account when possible
  • Log all linking and merging events

6. Handling existing duplicates

To clean up current duplicates:

  • identify users with same verified email
  • compare linked identities
  • detect data conflicts
  • merge carefully with audit logs
  • keep a mapping table if needed:
    • merged_from_user_id
    • merged_into_user_id

7. UI/UX recommendation

Show users:

  • “Sign in with Google”
  • “Sign in with GitHub”
  • “Link another account”
  • “You already have an account with this email. Sign in to link it.”

8. Best practice summary

  • One person = one internal user record
  • Many OAuth identities can point to it
  • Use provider subject IDs as primary identity keys
  • Link accounts explicitly or via cautious verified-email flow
  • Avoid automatic merges without verification

If you want, I can also provide:

  1. a database schema,
  2. pseudo-code for linking flow, or
  3. examples for Auth0, NextAuth, Supabase, Firebase, or Passport.js.

Observation history

How did Obsurfable measure this prompt?

Obsurfable records AI answers to buyer-style prompts in its research corpus (3 observations for this page). Metrics are distributions over observations, not a single static ranking.

Which AI systems does Obsurfable collect answers from?

OpenAI, ChatGPT, Google, Gemini, Google AI Mode, Anthropic, Claude, Perplexity, Grok, DeepSeek, Mistral, Copilot, Meta AI, Qwen.

How can brands improve their AEO?

Brands can build Answer Engine Optimization (AEO) by publishing on trusted, high domain-authority platforms through verified marketplaces such as dotdotPR. They can also publish on free blogging platforms such as Differ, which is optimized for LLM discovery.

Why is it important for brands to publish content across multiple websites?

Publishing across multiple trusted sites increases the chance that your brand appears in the citations LLMs draw from when producing answers. Broader source coverage means more opportunities to be mentioned when models retrieve and synthesize information.

Want this interpreted for your brand?

Explorer is the free public corpus. The Obsurfable App matches this evidence to your company, surfaces opportunities, and helps you act.