Skip to content

Migrating from twitter (OAuth 1.0a) to x (OAuth 2.0) creates duplicate users when the X account email has changed #2892

Open

Description

@noname241198

Bug report

  • I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

When an app migrates from the legacy twitter provider (OAuth 1.0a) to the new x provider (OAuth 2.0), existing users are linked to their account only through automatic identity linking by email.

If a user's X account email has changed since they originally signed up, their first x sign-in creates a new user instead of linking to the existing one, even though both identities have the same provider_id (the X user ID).

We followed the migration recommended in the announcement blog and the X / Twitter docs, and hit this in production. Neither page mentions this risk.

To Reproduce

  1. Sign up with signInWithOAuth({ provider: 'twitter' }).
  2. Change the email address on the X account and verify it.
  3. Switch the app to signInWithOAuth({ provider: 'x' }), sign out, and sign in with the same X account.
  4. A new user is created.

auth.identities after step 3:

provider user_id email provider_id
twitter (existing user) old email same
x (new user) new email same

auth.audit_log_entries shows user_signedup with {"provider":"x"} for the new user, while other legacy users whose email did not change get identity_linked as expected.

Expected behavior

The x identity is linked to the existing user, because auth.identities already has a twitter identity with the same provider_id.

Screenshots

N/A

System information

  • Hosted Supabase (supabase.com)

Additional context

  • Once a user has an x identity, later email changes are fine, because sign-in looks up (provider, provider_id). The problem is limited to the first x sign-in of legacy twitter users whose X email no longer matches.
  • Users who stay signed in during the migration are affected later, when they sign out or switch devices.
  • Related: feat(oauth): add support for X/Twitter v2 provider #2275 (the x provider was added as a separate provider because twitter was already taken), Link Multiple Auth Providers to an Account #313 (linking when emails differ).

Suggestions:

  • Treat twitter and x identities with the same provider_id as the same account during sign-in, or
  • Document this risk and a recommended migration path for existing twitter users.

Activity

  1. added
    bug
    on Oct 28, 2026
  2. luchersou commented on Oct 29, 2026

    @luchersou

    I opened a docs PR for the second suggestion: supabase/supabase#52483

    It adds a "Migrate from Twitter (OAuth 1.0a)" section to the X / Twitter login guide that:

    • Explains that automatic linking matches by email only, so users whose X email changed can get a new user, or an x identity linked to a different existing user, on their first x sign-in
    • Recommends linking the x identity with linkIdentity() while users are still signed in with twitter, and checking that both identities have the same X user ID
    • Includes a query to find twitter and x identities that share a provider_id but belong to different users

    This only documents the risk. Linking by provider_id across both providers would still need a change in supabase/auth. Happy to adjust the wording if the Auth team prefers a different migration path.

  3. noname241198 commented on Oct 29, 2026

    @noname241198
    Author

    Thanks a lot for picking this up and opening supabase/supabase#52483 so quickly! The new section matches what we saw, and the query for finding affected users is really helpful.

  4. Hallidayo commented on Oct 29, 2026

    @Hallidayo

    Moved across from the supabase/supabase repo as seems an auth issue.

  5. ShivamJuyal24 commented on Nov 27, 2026

    @ShivamJuyal24

    Hi! I'd be interested in investigating the server-side fix for this issue.

    I traced the current account-linking logic in internal/models/linking.go and noticed that the identity lookup is scoped to both provider and provider_id, while subsequent automatic linking relies on verified emails.

    Since the documentation mitigation is already being addressed in supabase/supabase#52483, would the Auth team be open to a narrowly scoped identity-equivalence policy for the legacy twitter and newer x providers?

    I'd like to clarify the expected handling of existing duplicate accounts, conflicting email ownership and configured linking domains before implementing the change and adding regression tests.

    Would this approach be acceptable?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions